Python Input Function -


i wondering if tell me wrong code, when run code shows nothing if take out "elif" work.\

first=input("what first name? "); middle=input("what middle name? "); last=input("what last name? "); test = [first, middle, last]; print (""); print ("firstname: " + test[0]); print ("middlename: " + test[1]); print ("lastname: " + test[2]); print (""); correct=input("this information input, correct? "); if (correct == "yes" or "yes"):     print ("good!") elif (correct == "no" or "no"):     print ("sorry there must error!"); 

here's problem:

if (correct == "yes" or "yes"):     # ... elif (correct == "no" or "no"):     # ... 

it should be:

if correct in ("yes", "yes"):     # ... elif correct in ("no", "no"):     # ... 

notice right way make comparison involving several conditions this:

correct == "yes" or correct == "yes" 

but gets written this, shorter:

correct in ("yes", "yes") 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -