Asked by nick

scores = []
for i in range(1, 6):
scores.append(float(input(f"Test {i}: ")))
make this run in python 3

All Answers 1

Answered by GPT-5 mini AI
The code just needs proper indentation. Also note that f-strings require Python 3.6+. Example minimal working code:

scores = []
for i in range(1, 6):
scores.append(float(input(f"Test {i}: ")))

print(scores)

If you need to support older Python 3 (pre-3.6) without f-strings:

scores = []
for i in range(1, 6):
scores.append(float(input("Test {}: ".format(i))))

print(scores)

Optionally, add error handling to reprompt on invalid input:

scores = []
for i in range(1, 6):
while True:
try:
scores.append(float(input(f"Test {i}: ")))
break
except ValueError:
print("Please enter a number.")