Modifying an element of a list in a function... What is an exact code?


#1

n = [3, 5, 7]
def double_list(x):
for i in range(0, len(x)):
x[i] = x[i] * 2
return x
print double_list(n)


#2

Hi your code is rigth may be it's a indent problem

n = [3, 5, 7]
def double_list(x):
    for i in range(0, len(x)):
        x[i] = x[i] * 2
    return x
print double_list(n)

#3

Okay... Thank you...


#4

i dont get why you put the line
for i in range(0, len(x)):
and what does it do ^


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.