1

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?

Innat
  • 16,113
  • 6
  • 53
  • 101
K. Taylor
  • 13
  • 1
  • 1
  • 3
  • What do you want to do with the grades? Depending on the intent, you could build a dictionary of grades, or build a list. Either way, you'd be able to access individual scores, as well as determine mean (and other values). – Stidgeon Feb 21 '16 at 04:13
  • Possible duplicate of [Print multiple arguments in python](https://stackoverflow.com/questions/15286401/print-multiple-arguments-in-python) – Innat May 14 '18 at 12:19

3 Answers3

1

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()
m_callens
  • 6,100
  • 8
  • 32
  • 54
1

Use .format, e.g.:

count = 0
while grade != "" :
    count += 1
    grade = input('quiz {}:'.format(count))
mechanical_meat
  • 163,903
  • 24
  • 228
  • 223
0

Of course, it is easy to make the variable within the str () function to convert it from a number to a string and to separate all the arguments using "+" and do not use "-" where programmatically when using "+" Python will be considered as one string

grade = input ("quiz 1: ")
count = 1
while grade != "" :
    count += 1
    grade = input ("quiz "+ str(count) + ": ")