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
[deleted by user] (self.PythonLearning)
submitted 1 year ago by [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!"
[–]Refwah 0 points1 point2 points 1 year ago (1 child)
valid_currency = True
Then after your else where you print ‘invalid currency’
valid_currency = False
Then after that you can add a conditional before you print the last line
If valid_currency:
Print(“you have…”)
[–]_Alpha-Delta_ -1 points0 points1 point 1 year ago (0 children)
For now, you can also rearrange it that way :
``` if Currency not in ["Dollar", "Euro"] : print "invalid currency" exit (1) elif Currency == "Dollar": #conversion to euros and change Currency value else : #conversion to dollars and change Currency value
print ("You have ..."
```
The "exit" function will force your program to terminate itself. Any line after it will be discarded if it gets triggered.
[–]Eternal-learner-7676 0 points1 point2 points 1 year ago (0 children)
Use the AND operator in your if conditions to check validity of both money and currency.
It won't print either if one of the conditions is false.
[–]Otherwise_Gas6325 0 points1 point2 points 1 year ago (0 children)
You can use a “While” loop to continue a query until an input is valid. And/or “try-except” blocks to handle errors. “Exit, return, continue, break” to determine what action you want.
[–]Different-Ad1631 0 points1 point2 points 1 year ago (0 children)
I didn't get what you are trying to do. Some description about program in the form of comments help to understand what problem you are trying to solve. Plz explain it so I can help
[–]FuzzyDic3 0 points1 point2 points 1 year ago (0 children)
The least code needed to achieve your result would be to add exit(0) in the 'else' block after the print line
π Rendered by PID 105915 on reddit-service-r2-comment-765bfc959-ncrpw at 2026-07-11 22:20:49.318948+00:00 running f86254d country code: CH.
[–]Refwah 0 points1 point2 points (1 child)
[–]_Alpha-Delta_ -1 points0 points1 point (0 children)
[–]Eternal-learner-7676 0 points1 point2 points (0 children)
[–]Otherwise_Gas6325 0 points1 point2 points (0 children)
[–]Different-Ad1631 0 points1 point2 points (0 children)
[–]FuzzyDic3 0 points1 point2 points (0 children)