Hi!
I had a different question:
Let’s say I want to add indexes to the cities_list with a zip()-function:
cities = ['London', 'Paris', 'Rome', 'Los Angeles', 'New York']
ind = list(range(5))
zip_cities = zip(cities, ind)
print(list(zip_cities))
This will output the cities unsorted. If I wanted to sort them alphabetically now, but keep the index numbers the same I would add
sorted_cities = zip_cities.sort()
by intuition. However, this would return:
sorted_cities = zip_cities.sort()
AttributeError: 'zip' object has no attribute 'sort'
How would I sort such a list alphabetically?
(In other words: Iwant to have [('London', 0), ('Los Angeles', 3), ('New York', 4), ('Paris', 1), ('Rome', 2)]
as output.)