can you help me with the exercises 11 and 12? This is my code so far:
destinations = ["Paris, France", "Shanghai, China", "Los Angeles, USA", "Sao Paulo, Brazil", "Cairo, Egypt"] test_traveler = ["Erin Wilkes", "Shanghai, China",["historical site", "art"]] def get_destination_index(destination): destination_index = destination.index() return destination_index print(get_destination_index("Los Angeles, USA"))
In bash it gives me TypeError, saying “index ( ) takes at least 1 argument (0 given)”. What exactly should I do?
This is the best I could do but still doesn’t work well, instead of index 2 it gives me 0:
def get_destination_index(destinations): destination_index = destinations.index(str(destinations)) return destination_index print(get_destination_index("Los Angeles, USA"))
Here I changed the name of the function’s parameter from destination to destinations, although the project itself tells me to name it destination. I did it so because "Los Angeles, USA’’ makes part of the already defined variable of destinations, and not destination.