Spoiler

I’m going to break this down as the problem was hard to understand at first, so this should help most or all of you.

===============================================================================
Create a function named double_index that has two parameters named lst and index .
#### So far the first line is def double_index(lst, index):

The function should double the value of the element at index of lst and return the new list with the doubled value.
#### This is saying from Greek to English is that ‘index’ is the element, meaning the variable inside
#### the , or the brackets. Now ‘of’ means the variable that is going to work with the
#### elements
#### Now that we understand that.
#### lst[index] * 2 , as it is requested it will be doubled.

If index is not a valid index, the function should return the original list.
#### so if ‘index’ is not the right one, it should return back to the original. So what exactly does
#### that mean considering valid is only permitted if the statement itself (if, else statements) is
#### correctly written? This is the only part I did not grasp as the conclusion has a ‘less than’ than a
#### valid statement. I would have to say that this statement itself is not valid unless someone
#### else can provide references that I am missing something.
#### index < lst[index]:
#### return index
#### Again not sure how less than is counted as valid, but oh well.

After writing your function, un-comment the call to the function that we’ve provided for you to test your results.
#### This is in English now.

===============================================================================
Finally the final outcome further broken down.

Original Conclusion:
def double_index(lst, index):
if index < len(lst):
lst[index] = lst[index] * 2
return lst

Decrypted of what its doing. I calculated of what its extracting and using.

def double_index(lst, index):
if index < len(lst):

if 2 < 3:

 lst[index] = lst[index] * 2

(3, 8, -10, 12)[2] = (3, 8, -10, 12)[2] * 2

-10 = (-10 * 2)

     return lst

#Uncomment the line below when your function is done
print(double_index([3, 8, -10, 12], 2))

1 Like

I put the conclusion at the bottom and explained why.

Thank you for posting this. I agree with the other comments here that this exercise is a bit advanced compared to the course material and should be rewritten to reduce friction (esp if a goal is to get people to upgrade to Pro!).

3 Likes