(May-18-2018, 04:24 PM)wavic Wrote: Post the code, please!
print("No.\tCountries\t\t\t Capitals\n ") f = open(r'C:\Users\USER\Desktop\Notepad_Read\countries.txt') count = 0 data = f.readlines() for line in data: line = line.rstrip('\n') rec = line.split(',') country = rec[0] capital = rec[1] count = count + 1 print("{0:1}\t{1:26}\t {2:24}".format(count,country,capital)) while (True): line = str(input("Enter a country name (x to Exit): ")) if line == 'x': break elif line == country: print ("The capital of {0} is {1}".format(country,capital)) else: print("The country is not in the list. Please try again.") f.close()It could read Russia only. Other countries it couldn't be executed...
PS: Somehow I restart the Spyder then it worked.