I am brand new to python and am struggling with while loops and how inputs dictate what's executed. Here is what I am looking for: If the user inputs an invalid country Id like them to be prompted to try again. If they enter a valid country Id like the code to execute. lastly if they type 'end' when prompted to enter a country id like the program to end. Here is what I have so far:
while True:
my_country = input('Enter a valid country: ')
if my_country in unique_countries:
print('Thanks, one moment while we fetch the data')
Some code here
#Exit Program
else:
my_country == "end"
break
The problems I am running into is that, as currently written, if I enter an invalid country it ends the program instead of prompting me again. Thank you in advance. I am also new to stack overflow, sorry for the horrible formating.