12.List Item by Item


#1



unable to understand logic and function can any help me in this matter


Oops, try again. The body of your function should not contain any references to 'n'


i have change n to x also
and call the function from outside the loop also.


n = [3, 5, 7]

def print_list(x):
    for i in range(0, len(n)):
        print n[i]
    
print_list(n)


#2

def print_list(x):
    for i in range(0, len(x)):
        print x[i]
    return x

print_list(n)

is this correct ?


#3

you don't have to return x, but yes, its right :slight_smile:

Do you have any questions about it?


#4

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