I am learning python now and need a solution for this problem!
city_indices = list(range (0,len (cities)))
city_indices [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]
city_names = ['Buenos Aires','Toronto','Pyeongchang','Marakesh', 'Albuquerque', 'Los Cabos', 'Greenville', 'Archipelago Sea', 'Walla Walla Valley', 'Salina Island', 'Solta', 'Iguazu Falls']
Your task is to assign the variable names_and_ranks to a list, with each element equal to the city name and it's corresponding rank. For example, the first element would be, "1. Buenos Aires" and the second would be "2. Toronto". Use a for loop and the lists city_indices and city_names to accomplish this.
names_and_ranks = ['change this to different elements'] # make sure the list is empty
names_and_ranks[0] # '1. Buenos Aires'
names_and_ranks[1] # '2. Toronto'
names_and_ranks[-1] # '12. Iguazu Falls'
Thanks for help. I found the solution
names_and_ranks = []
for index in city_indices:
names_and_ranks.append(f"{index + 1}. {city_names[index]}")