-3

I know this might be a simple question but I can't seem to figure how to put a string after the for loop variable

stud_num = int(input("How many students do you have? "))
test_num = int(input("How many test for your module? "))
score = 0
for i in range(stud_num):
    print("******** Student #", i+1, "********")
    for s in range(test_num):
        print("Test number ", end="")
        score1 = float(input(s+1))
        score += score1

My sample output for asking the question would be

Test number 1 :

but now my current output from

print("Test number ", end="") 

score1 = float(input(s+1)) is Test number 1

I can't figure out how to put the ": " into the input because it gives me an error saying that it expects an int but gets a str

FlyingTeller
  • 13,811
  • 2
  • 31
  • 45
Kovi
  • 63
  • 1
  • 10

2 Answers2

1

Don't split your prompt between a print and the input. Just use a format string in the input prompt:

score1 = float(input("Test number %d: " % (s+1)))

Or using str.format:

score1 = float(input("Test number {}: ".format(s+1)))
tobias_k
  • 78,071
  • 11
  • 109
  • 168
0

OR the new f-strings, only allowed after python 3.6:

score1 = float(input(f"Test number {s+1}: "))
U12-Forward
  • 65,118
  • 12
  • 70
  • 89