Question: I am trying to find an element in a list (string) and then print the index. Here is my code:

```
def checkLen():
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
position = 0
for i in days:
    if i == "Monday":
        position = i
        print("Found it")
        print(position)

```

But i am getting the result:

```
Found it
Monday

```

I have discovered that ,unlike other programming language that i know, Python variable type can change, which is why the Number type "position" changes to a "str", how do i save the index in position?

Answer: 
Lists have an index method that you can use

```
def checkLen(): 
     days = ["Monday", "Tuesday", "Wednesday", "Thursday" "Friday", "Saturday", "Sunday"]
     try:
         position = days.index("Monday")
         print("Found it") 
     except ValueError:
         position = None # or 0 if you want
         print("Not present") 
     print(position)

```
there is an index function for lists:

```
days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
print(days.index("Monday"))

```

note that this will raise an exception if the item is not in the list but will execute faster than looping over the list, especially if you have long lists.

however it will only give you the first index, so if there are duplicates you'll have to use other methods to find them.

a good resource for reading is <http://effbot.org/zone/python-list.htm>

as pointed out by Frerich Raabe
in python most people tend to write code to assume that what you are looking for is there (ie the list has the element you are trying to find) and catch the exception raised if its not (exception raised is ValueError)

try not to use a general exception when you know the specific exception that should be raised as with more complex code it can make it harder to find other problems where another function call fails.