Making function to report odd numbers in a list

I tried making a simple function that reports back all of the odd numbers in the range of a given list.

I was confused when I ran the function and it gave me all of the odd numbers except one.

Hi there!

By using the range funcion, now you are actually iterating over a list that looks something like this:

0, 1, 2, 3, 4, 5, 6
(you said you wanted it to start at zero, and end at the lenght of the list minus one)

Instead of iterating over the list that you gave as a parameter.

I would just get rid of the range function and iterate directly over the lst parameter.

1 Like