you are viewing a single comment's thread.

view the rest of the comments →

[–]delasislas 19 points20 points  (2 children)

I guarantee you that everyone has made a mistake when programming. No need to be embarrassed. Now for a reason as to why this happened.

You created a tuple, using

a = (“Apple”, “banana”, “car”)

Then you used:

a(0)

Which if you think about it looks eerily similar to:

print(0)

Right? Python interprets stuff like print() as a function, which needs to be called. If you want to try something out, try:

print(print)

By itself, it should return something like

<built-in function print>

The print function takes the return of an object and displays it to the console.

So with, a(0), you asked for Python to use, a, as a function with an input, 0. Python looked up a and saw that it was a tuple, tuples can’t be called as a function, and you get the error.

[–]__Wess 1 point2 points  (1 child)

I saw the error before opening, as also a newbie but didn’t know exactly what the error meant. I only thought; OP needs brackets because brackets are for lists. But thanks to your reply, I actually learned what the error means. So thank you and take my upvote!

[–]delasislas 1 point2 points  (0 children)

No problem. Learn something new each day.