0

A similar answer

I'm making a basic text adventure game for the first time in PyDev in Eclipse and when I try to have the user give input more than once I get the above error. Below is the code I used that generated the error:

print("Input a name for your character.")    
input = input()    
player = Character(input)

I already have the class Character defined and it takes a str as its argument. The setter is below.

player.setName(input)    
print("\nWelcome, "+input+"!\nChoose a weapon from the list below.")    
print("\nfists\ndagger\nspear\naxe\nshortsword\nlongsword\nmace")    
wpn = input()

I get a TypeError on the line with wpn = input()" saying 'str' object is not callable.

This confuses me because, shouldn't this take input and store it in a new variable "wpn" where once it was stored in "input"? When I change wpn to input it works, but not if I ask it to take user input...

I want unique user inputs each time, but I'm not sure how to accomplish that given this error.

1
  • 2
    You assigned the user's input to the variable input. After that point, you can no longer call input(), because that name no longer refers to the built-in function. Just choose a different variable name there. Commented Aug 3, 2018 at 4:06

2 Answers 2

0

You've changed input to be a string. It's no longer what the original input function does. Give the value that input returns a different name:

user_input = input()

This will keep the input function as it is.

Sign up to request clarification or add additional context in comments.

Comments

0

It is not working because your variable input is overwriting the real input function, so the best way to solve this is to rename the variable, try this:

user_input = input()

Now it won't overwrite the function

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.