Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with code
#1
I'm just trying out Python today and I tried to do some code and I got this error
print ("no")
myting = "hello world"
print = (myting)
mynem = input("What is your Name?")
myvar = input("I need a number :")

if(mynem == "Snek" and myvar != "0"):
	print("big vag")
elif(mynem == "majeff"):
        print("badjoke")
else:
	print("okgood")
Error:
Output:
Traceback (most recent call last): File "C:\Users\[my rl name]\Desktop\nonono.py", line 12, in <module> print("okgood") TypeError: 'str' object is not callable
I tried to look it up what that means but I don't understand it.
Reply
#2
When using if and else statements the action has to be indented 4 spaces
Gary
Reply
#3
change
print = (myting)
to

print(myting)
Reply
#4
like this?

if(mynem == "Snek" and myvar != "0"):
print("big vag")
elif(mynem == "majeff"):
print("badjoke")
else:
print("okgood")

(ignore that)
Reply
#5
Please use python and output tags when posting code and results. I put them in for you this time. Here are instructions for doing it yourself next time.

The problem is line 3. That assigns the string value 'hello world' to the name print, instead of printing it. Then, when you try to call the print function later, it is no longer a function, so it can't be called. I think you want to remove the equals (=) from line 3.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020