Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What needs to be changed about this code for it to run properly? validChoice = True while not validChoice: animal = input(Enter an animal you

What needs to be changed about this code for it to run properly?

validChoice = True while not validChoice: animal = input("Enter an animal you want for a pet: ") locale = input("Enter continent where you want to live: ") if animal == "giraffe" and locale == "Africa": validChoice = False elif (animal == "dog" or animal == "cat") and locale != "Antarctica": validChoice = False elif animal == "rabbit" and locale != "Australia": validChoice = False else: print("Sorry, that's not a good place for that animal to live.")

Start with validChoice equal to False, and set it to True inside the if/elif statements

Start with validChoice equal to False, and set it to True as soon as we enter the while loop

Change the elif statements to if statements, and remove the else

Don't set validChoice until we're inside the loop

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions

Question

What is the cerebrum?

Answered: 1 week ago

Question

Writing a Strong Introduction

Answered: 1 week ago