Posted By: Anonymous
Using the code below:
print("Welcome to band name generator!!") city,pet = input("What is the name of the city you grew up in?t") + input ("nWhat is the name of your first pet?t") print("nt Your band name can be " + city + " "+ pet + "!!")
I can input single variable (eg – a/b/c or 1/2/3) and the program works fine but it we input string values or words(eg- Canada,New_york), I get the following error –
too many values to unpack (expected 2)
How can I resolve this while keeping input in one line?
You need to replace the
+ with a
, since the
+ is going to concatenate your inputs into one string.
city, pet = input("What is the name of the city you grew up in?t"), input ("nWhat is the name of your first pet?t")
Whenever you get the
too many values to unpack Error, make sure that the number of variables on the left side matches the number of values on the right side.