Double index


#1

Https://www.codecademy.com/paths/computer-science/tracks/cspath-flow-data-iteration/modules/dspath-lists/lessons/python-functions-lists-cc/exercises/double-index

Hi,

I don’t really understand the Codecademy solution to this problem - don’t you have to return the doubled value in order to print anything? And how does this code know to return the original list if the condition (i.e. index < eln(lst)) isn’t met? My code is below and seems to work also… but would love to know how the shorter more elegant code works! Any help much appreciated!


#2

Your program returns only the doubled value, not the modified list.

return (lst[index] * 2)

#3

Ahhh hadn’t read the question properly! Thanks very much :slight_smile: