Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTimothy Tseng
3,292 PointsValidating user inputs
def prompt_user():
option = input("Please select an option, to view options type in 'HELP' ")
if option != '1' or '2' or 'DONE' or 'HELP':
print("Invalid option, type HELP for valid commands. ")
How come in the above code when I type in DONE or HELP in the command my program is saying it's invalid? I also tried without the single quotes. I'm guessing it's because I have both string and ints in the same line?
1 Answer
jhon white
20,006 PointsYour code has two things wrong : 1- You should use (and) not (or) . 2- The condition should be used for every statement . here is: def prompt_user(): option = input("Please select an option, to view options type in 'HELP' ") if option != '1' and option !='2' and option !='DONE' and option !='HELP': print("Invalid option, type HELP for valid commands. ")
prompt_user()
ps: your numbers('1','2') are strings too. Good luck!!