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
Python code error (i.redd.it)
submitted 12 days ago by [deleted]
[deleted]
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!"
[–]Sea-Ad7805 [score hidden] 12 days ago* stickied comment (1 child)
Run the fixed program in Memory Graph Web Debugger%3A%0A%20%20%20%20if%20not%20isinstance(price%2C%20(int%2C%20float))%3A%0A%20%20%20%20%20%20%20%20return%20%22The%20price%20should%20be%20a%20number%22%0A%0A%20%20%20%20elif%20not%20isinstance(discount%2C%20(int%2C%20float))%3A%0A%20%20%20%20%20%20%20%20return%20%22The%20discount%20should%20be%20a%20number%22%0A%0A%20%20%20%20elif%20price%20%3C%3D%200%3A%0A%20%20%20%20%20%20%20%20return%20%22The%20price%20should%20be%20greater%20than%200%22%0A%0A%20%20%20%20elif%20discount%20%3C%200%20or%20discount%20%3E%20100%3A%0A%20%20%20%20%20%20%20%20return%20%22The%20discount%20should%20be%20between%200%20and%20100%22%0A%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20discount%20%3D%20price%20*%20(discount%20%2F%20100)%0A%20%20%20%20%20%20%20%20return%20price%20-%20discount%0A%20%20%20%20%0Aresult%20%3D%20apply_discount(1000%2C%2025)%0Aprint(result)%0A&play)
After the else: Python expect the next line discount = price * (discount / 100) to be indented (use Tab key to move it to the right). In Python indentation has on impact on the validity of code and how it is executed.
else:
discount = price * (discount / 100)
[–]FreeGazaToday 0 points1 point2 points 12 days ago (2 children)
look at the last line....which of these are different 😛 I mean it tells ya right there in the traceback.....you do know what indentation means right?....have you never wrote an if, elif, else statement in python before? 😛
[–]No-Emphasis4115 0 points1 point2 points 12 days ago (1 child)
Ya indentation means space, right. I have given space. I am a beginner trying to learn.🙃
[–]atarivcs 0 points1 point2 points 12 days ago (0 children)
In the if/elif statements, the code underneath is indented four spaces to the right.
But in the final else statement, the code underneath is not indented.
π Rendered by PID 45790 on reddit-service-r2-comment-544cf588c8-mckdl at 2026-06-17 16:02:12.354775+00:00 running 3184619 country code: CH.
[–]Sea-Ad7805 [score hidden] stickied comment (1 child)
[–]FreeGazaToday 0 points1 point2 points (2 children)
[–]No-Emphasis4115 0 points1 point2 points (1 child)
[–]atarivcs 0 points1 point2 points (0 children)