Python Error - Typeerror: Input Expected at Most 1 Arguments, Got 3 [Duplicate]

Can someone explain why I can not use your_name in the goal variable?

my_name = "Bryson"
my_age = 29
your_name = input ("What is your name? ")
your_age = input ("What is your age? ")
print ("My name is", my_name,", and I am", my_age, "years old.")
print ("Your name is", your_name,", and you are", your_age,".")
print("Thank you for buying my book,", your_name,"!")
goal = input ("What was your favorite part of the book,", your_name, "?")
print("Awesome!")

The error I get is:

goal = input ("What was your favorite part of the book,", your_name, "?")
TypeError: input expected at most 1 arguments, got 3
1

You got that error because you in fact gave 3 arguments to the input function when it was only expecting 1 (namely, a string prompt).

In input ("What was your favorite part of the book,", your_name, "?")
           ---------------------------------------- , ---------, ---

The underlined parts are the comma-separated arguments: a string ("What is ....book", a variable your_name, and another string, "?"

I think what you wanted was

goal = input("What was your favorite part of the book, " + your_name + "?")

Here the concatenation operator + combines those ingredients into a single string -- and a string is the one argument that input is expecting

2

Try this:

goal = input ("What was your favorite part of the book, %s ?" % your_name)

2
input(print("What was your favorite part of the book, " + your_name + "?"))
1
Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest