The Boredless Tourist - list.index() method

At what point was the .index list method taught in the computer science career path? Task 8 stumped me for so long until I watched the guided video and viewed the hint where they both refer to the .index method. Did I overlook this or was it not taught prior to this project?

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

Thank you!

Are we to understand that you are referring to list.index() method?

As in,

destinations = [“Paris, France”, “Shanghai, China”, “Los Angeles, USA”, “Sao Paulo, Brazil”, “Cairo, Egypt”]

print (destinations.index("Sao Paulo, Brazil"))
# 3

Or, is it the indices of the list that are in question?

print (destinations[3])
# Sao Paulo, Brazil
1 Like

The list.index() method, I just don’t recall learning it prior to this project.

For example, in the video it points to this string of code to find the index value.

def get_destination_index(destination):
   destination_index = destinations.index(destination)
   return destination_index

I understand what the code is doing I was just very confused when they put this list.index()in without teaching it prior. And I could be mistaken, they might have taught it in the computer science path, section 1-3, but I have not been able to find it and would just like to review the section the information came from.

Because it wasn’t introduced earlier in the course, as far as I know. The main goal of projects is to reinforce already gained knowledge and to introduce users to the problems that they might meet in a real life scenarios.

Step 9:

In the body of get_destination_index(), find the index of destination and save the results into a variable called destination_index.

This should be enough to google “python how to find index”.

Hint of step 9:

Use the list method .index() that finds the index of a given argument.

This should be enough to google “python index method”.

It’s impossible to cover all the methods and quirks of a given language. Programmers must know that there is a lot of knowledge in the external resources like documentations, forums, articles, QA platforms.


Oh I see, I figured projects would just be reinforcing information that was previously taught. I will keep this in mind for future projects and courses. Thank you!

1 Like

No problem :slight_smile: There are no many steps that require you to go a little bit deeper but trust me - this is a very valuable experience.

By the way, if you would like to learn what methods are available for the list datatype, this is the official Python documentation ->