Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Python list while loop check

my aim is to run the while loop until the user inputs a option that is in my list. If they do the while loop should end.

exchangeCurrency = input("what currency would you like to convert to: ").upper()

myList = ["USD", "ERU", "BRL", "JPY", "TRY"]

while exchangeCurrency != myList:
    print("this is not a valid inpit")
    continue
else:
    break

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

while True:
    exchangeCurrency = input("what currency would you like to convert to: ").upper()
    if exchangeCurrency in myList:
        break
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading