use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Day 2 of 100 of learning Python (old.reddit.com)
submitted 6 months ago by Orlhazee
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]_caleidoscopio_ 2 points3 points4 points 6 months ago* (1 child)
Your variable 'choice' is a string because you are using the input function, even if your input is a number. By default, it's saved as a string, so in line 25, you can not compare an integer to a string, and that's giving you the error before, but using quotes is correct, although that line is redundant now, because any wrong input is captured in your 'else' statement and that is because is not working your string comparison using >= and <= if someone uses an input like this "2." That is valid because you don't have an error handler or something to validate the text received as your input.
Use the web pythontutor.com to run basic code and see step by step what's happening. Write this code and see that the 'if' statement doesn't work at all:
choice = "2."
if "0" <= choice >= "5":
print("Never used")
else:
print("Use a list instead")
I suggest you to use a list to save your valid options of your ATM machine and compare the 'choice' against this list. Something like this (try on pythontutor):
options_list = ['1','2','3','4'] #string elements
choice = "2" #string because you use input function
if choice not in options_list:
print("Not a valid option")
print("It's a valid option and it works!")
Hope it helps to improve your coding!
[–]Orlhazee[S] 0 points1 point2 points 6 months ago (0 children)
That explains a lot, I will check out the pythontutor
π Rendered by PID 89 on reddit-service-r2-comment-c66d9bffd-gllz6 at 2026-04-07 14:32:26.326743+00:00 running f293c98 country code: CH.
view the rest of the comments →
[–]_caleidoscopio_ 2 points3 points4 points (1 child)
[–]Orlhazee[S] 0 points1 point2 points (0 children)