Print_list(n) instead of print list(n)


#1



https://www.codecademy.com/courses/python-beginner-nzzVa/3/1?curriculum_id=4f89dab3d788890003000096#


No, I don't stuck. I just don't understand something.


I don׳t understand why I have to write print_list(n) instead of print list(n).


Code:
Works:
n = [3, 5, 7]
def print_list(x):
    for i in range(0, len(x)):
        print x[i]
print_list(n)

Does not work:
n = [3, 5, 7]
def print_list(x):
    for i in range(0, len(x)):
        print x[i]
print list(n)


#2

1.) "Define a function called print_list that has one argument called x."

I would assume this is so because the instructions tell you you have to use print_list. Also, your not really printing list(n) your calling print_list with n in the parameters. Maybe it would have been a little clearer if they had not used print in the function name but that is what they decided on.


#3

Thank you!:slight_smile:


#4

No problem! Happy coding! :smiley:


#5

Wow! You respond really fast!


#6

Well when I am on I ain't a super user for nothing :stuck_out_tongue: haha but especially when talking with people about their coding problems and all I feel like I should respond as quick as possible just to be more considerate of their time :sunglasses:


#7

very funny.......... :smile:


#8

So it should not be print print_list? Why it works also with print_list ?! :slight_smile:


#9

Well once again your not printing your calling your function. It just so happens that your calling a function with print in its name. So if you are just glancing at your code it looks like your printing something when your not xD that is why it can get a little confusing and I think using a function name with print in it was a mistake but whatevah :smiley:


#10

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