pythonpython-3.xprintingarguments

Multiple Arguments in an Input?


Beginner Programmer here. I'm trying to write a program that will ask a user for a quiz grade until they enter a blank input. Also, I'm trying to get the input to go from displaying "quiz1: " to "quiz2: ", "quiz3: ", and so on each time the user enters a new quiz grade. Like so:

quiz1: 10 
quiz2: 11
quiz3: 12

Here's what I've written so far:

grade = input ("quiz1: ")
count = 0
while grade != "" :
    count += 1
    grade = input ("quiz ", count, ": ")

I've successfully managed to make my program end when a blank value is entered into the input, but when I try to enter an integer for a quiz grade I receive the following error:

Traceback (most recent call last):
  File "C:\Users\Kyle\Desktop\test script.py", line 5, in <module>
    grade = input ("quiz ", count, ": ")
TypeError: input expected at most 1 arguments, got 3

How do I include more than one argument inside the parenthesis associated with the grade input?


Solution

  • The input function only accepts one argument, being the message. However to get around it, one option would be to use a print statement before with an empty ending character like so:

    .
    .
    .
    while grade != "":
        count += 1
        print("quiz ", count,": ", end="")
        grade = input()