I have a textfile that has a city and a number on each line like this:
city1 15
city2 25
city3 2
city4 8
city5 10
I want to print the cities in order from the lowest number to the hights
The print should look like:
city3, city4, city5, city1, city2
Tried this:
lst = []
with open('livrari.txt', mode='r') as my_file:
for line in my_file:
lst.append(line.strip())
lst.sort()
print(lst)
This gives me a list of lists containing the city and the number. Can someone help me finish this?