Tuesday, 15 February 2011

python - TypeError: input expected at most 1 arguments, got 3 -



python - TypeError: input expected at most 1 arguments, got 3 -

i'm making little guessing game in python computer guesses number chosen player.

# computer guessing game # computer tries guess number print("think of number, , seek guess it. if guess right,") print("say 'yes'.if guess high, 'lower'. , if guess is") print("too low, 'higher'.\n") reply = input("is 50? ") guess = 50 while reply != "yes": hilo = input("is higher or lower? ") if hilo == "lower": guess %= 50 reply = input("is it", guess, "?") if hilo == "higher": guess %= 150 reply = input("is it", guess, "?") print("i win!") input("press come in key exit.")

however, when running it, lines 15 , 18 of code

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

return "typeerror: input expected @ 1 arguments, got 3" don't know how prepare this, help much appreciated.

input accepts one argument, passing 3. need utilize string formatting or concatenation create 1 argument:

answer = input("is {} ?".format(guess))

you confusing print() function, indeed take more 1 argument , concatenate values 1 string you.

python

No comments:

Post a Comment