Python Error - TypeError: input expected at most 1 arguments, got 3 -
can explain why can not use your_name in goal variable?
my_name = "bryson" my_age = 29 your_name = input ("what name? ") your_age = input ("what age? ") print ("my name is", my_name,", , am", my_age, "years old.") print ("your name is", your_name,", , are", your_age,".") print("thank buying book,", your_name,"!") goal = input ("what favorite part of book,", your_name, "?") print("awesome!")
the error is:
goal = input ("what favorite part of book,", your_name, "?") typeerror: input expected @ 1 arguments, got 3
you got error because in fact gave 3 arguments input
function when expecting 1 (namely, string prompt).
in input ("what favorite part of book,", your_name, "?") ---------------------------------------- , ---------, ---
the underlined parts comma-separated arguments: string ("what ....book", variable your_name
, , string, "?"
i think wanted was
goal = input("what favorite part of book, " + your_name + "?")
here concatenation operator +
combines ingredients single string -- , string 1 argument input
expecting
Comments
Post a Comment