Python Challenge: Double Index

Hello,

I got a problem I hope someone can help me pout with.
Python Challenge: Double Index

def double_index(lst, index):
    if lst[index] <= 0 or float(lst[index]):
        return lst
    else:
        pop_index = lst.pop(index)
        double_pop = pop_index * 2
        lst.insert(index, double_pop)
        return lst

when I check my answer - I get, “Make sure to define what should happen if index is too big!”

However, the instructions only state “If index is not a valid index, the function should return the original list.” - Which I attempt to do on line 3.

Thanks for any help!

Yes, but if the list index is too big, it is still invalid.

An invalid index is one which is greater than or equal to the length of the list (index >= len(list))

1 Like

aah, that makes sense now (I feel silly) - thank you so much! :crazy_face:

2 Likes