Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get "TypeError: input expected at most 1 arguments, got (more than 1)"?

Tags:

python

I'm making a small guessing game in Python where the computer guesses a number chosen by the player. I'm getting an error when I try to ask for user input:

answer = input("Is it", guess, "?")

This line throws

TypeError: input expected at most 1 arguments, got 3

What am I doing wrong?

like image 934
Francois Avatar asked Sep 19 '25 20:09

Francois


1 Answers

input only accepts one argument, but you are passing it 3. You need to use string formatting or concatenation to make it one argument:

answer = input(f"Is it {guess} ?")

You were confusing this with the print() function - which does indeed take more than one argument, and will concatenate the values into one string for you.

like image 129
Martijn Pieters Avatar answered Sep 21 '25 13:09

Martijn Pieters