LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-24-2014, 08:22 AM   #1
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 542

Rep: Reputation: 79
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)) 
 
Old 06-24-2014, 08:52 AM   #2
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
this line:
Quote:
Originally Posted by angel115 View Post
PHP Code:
print = ("You are a"
shuld be:
PHP Code:
print ("You are a"
 
1 members found this post helpful.
Old 06-24-2014, 08:57 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,692

Rep: Reputation: 7275Reputation: 7275Reputation: 7275Reputation: 7275Reputation: 7275Reputation: 7275Reputation: 7275Reputation: 7275Reputation: 7275Reputation: 7275Reputation: 7275
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
 
1 members found this post helpful.
Old 06-24-2014, 09:10 AM   #4
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 542

Original Poster
Rep: Reputation: 79
Oh....

Thanks; it's working.

I'll change my glasses, I promess.

 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Python object comparison 0x53h Programming 3 12-19-2013 01:26 PM
[SOLVED] Python TypeError when calling Python program from a Bash script noppeli Programming 2 01-15-2013 08:06 AM
python os.system() or subprocess.Popen() TypeError on ubuntu lucid 10.04 sahar.gh Programming 1 06-25-2012 07:56 PM
[SOLVED] python3 - trying to pickle object raises TypeError comp_brad1136 Programming 2 04-06-2011 07:37 AM
[SOLVED] Python cannot concatenate 'str' and 'NoneType' objects madsovenielsen Programming 4 06-24-2010 01:44 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration