I have created a function that takes a text file of countries, puts it in a list, then asks a user for a country of residence, if the country is invalid then the program is supposed to continuously ask the user for a valid country, and it works, but if the country is valid, then the shell says that it is completing the action but it never actually completes it. Does anyone have any suggestions for fixing this?
def real_country(variable): #function to determine if the country inputted for a new
user is valid
countries = open('country list.txt', 'r+')
country_list = countries.readlines()
for i in range(len(country_list)):
country_list[i] = country_list[i].strip('\n')
for i in range(len(country_list)):
if country_list[i] == variable:
return True
print are you a new or existing user?
exisitngORnew = raw_input()
if existingORnew == 'new':
Real_Country = 'unknown'
print 'What is your country of residence'
country = raw_input()
while Real_Country == 'unknown':
if real_country(country) == True:
Real_Country == country
else:
print 'Please enter a real country'
country = raw_input()
print 'program finally works!'