Im doing the Boredless Tourist on Codeacademy and for some reason I can’t get # 20 right, here’s the code dunno why it comes as an error and won’t print. the last part is what I need, thanks.
destinations = [“Paris, France”, “Shangai, China”, “Los Angeles, USA”, “São Paulo, Brazil”, “Cairo, Egypt”]
test_traveler = [‘Erin Wilkes’, ‘Shanghai, China’,[‘historical site’, ‘art’]]
def get_destination_index(destination):
destination_index = destinations.index(destination)
return(destination_index)
print(get_destination_index(“Los Angeles, USA”))
#get_destination_index(“Hyderabad, India”)
def get_traveler_location(traveler):
traveler_destination = traveler[1]
traveler_destination_index = get_destination_index(traveler_destination)
return (traveler_destination_index)
test_destination_index = get_traveler_location(test_traveler)
print(test_destination_index)
prints:
2
Traceback (most recent call last):
File “script.py”, line 16, in
test_destination_index = get_traveler_location(test_traveler)
File “script.py”, line 13, in get_traveler_location
traveler_destination_index = get_destination_index(traveler_destination)
File “script.py”, line 6, in get_destination_index
destination_index = destinations.index(destination)
ValueError: ‘Shanghai, China’ is not in list