Can someone tell me what went wrong with this python code please? It looks silly as the code is pretty simple but I am a beginner in coding, hopefully understandable.
f = open("countries.txt", "r")
countries = []
for line in f:
line = line.strip()
countries.append(line)
f.close()
print(countries)
print(len(countries))
for country in countries:
if country[0] == "T":
print(country)
I keep getting the following error:
line 16, in <module>
if country[0] == "T":
IndexError: string index out of range