2

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?

4
  • 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). Commented Feb 21, 2016 at 4:13
  • Possible duplicate of Print multiple arguments in python Commented May 14, 2018 at 12:19
  • This question is similar to: Why do I get "TypeError: input expected at most 1 arguments, got (more than 1)"?. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. Commented Sep 10, 2024 at 20:21
  • @Innat no, this is a different question. Commented Sep 10, 2024 at 20:21

3 Answers 3

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()
Sign up to request clarification or add additional context in comments.

Comments

1

Use .format, e.g.:

count = 0
while grade != "" :
    count += 1
    grade = input('quiz {}:'.format(count))

Comments

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) + ": ")

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.