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...
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
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
Try this:
goal = input ("What was your favorite part of the book, %s ?" % your_name)
input(print("What was your favorite part of the book, " + your_name + "?"))