LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Python: error - TypeError: 'str' object is not callable (https://www.linuxquestions.org/questions/programming-9/python-error-typeerror-str-object-is-not-callable-4175509014/)

angel115 06-24-2014 08:22 AM

Python: error - TypeError: 'str' object is not callable
 
Hi there,

I'm new to python and here is one of my first try.
I'm getting the following error and II'd like to understand why.

Here is what happen when I start the program

$ ./second.py
Traceback (most recent call last):
File "./second.py", line 8, in <module>
print (adjective)
TypeError: 'str' object is not callable


PHP Code:

#!/usr/bin/python3

from random import choice
adjectives 
= ["wet""big"]
mouns = ["turnip""dog"]
print = (
"You are a")
adjective choice (adjectives)
print (
adjective)
print (
choice (mouns)) 


schneidz 06-24-2014 08:52 AM

this line:
Quote:

Originally Posted by angel115 (Post 5193098)
PHP Code:

print = ("You are a"


shuld be:
PHP Code:

print ("You are a"


pan64 06-24-2014 08:57 AM

in this line:
print = ("You are a")
the equal sign made a problem, you redefined the print keyword...
print ("You are a")
whould be better I think

angel115 06-24-2014 09:10 AM

Oh....

Thanks; it's working.

I'll change my glasses, I promess.

:)


All times are GMT -5. The time now is 10:03 AM.