The Boredless Tourist


#1
destinations=['Paris,France','Shanghai,China','Los Angeles,USA','Sao Paulo,Brazil','Cairo,Egypt']

test_traveler=['Erin Wilkes', 'Shanghai, China', ['historical site', 'art']]

print(destinations.index('Los Angeles,USA'))

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('Shanghai,China'))

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)

I am getting following error message, not getting where went wrong? Could you help me please?

ValueError ‘Shanghai, China’ not in list.


#2

I believe your error is caused by the space in between Shanghai, China. In your destinations data set there is no space between the comma and China but in your test_traveler data set there is a space between the comma and China.


#3

Thank you. It worked.