-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
  • 17,638
  • 3
  • 38
  • 53
Alexio
  • 75
  • 1
  • 11

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
  • 81,265
  • 12
  • 120
  • 179
0

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

score1 = float(input(f"Test number {s+1}: "))
U13-Forward
  • 69,221
  • 14
  • 89
  • 114