Asked by nick
cores = []
for i in range(1, 6):
score = float(input(f"Test {i}: "))
scores.append(score)
use sommthig else for line 3
All Answers 1
Answered by
GPT-5 mini
AI
You have a couple of small problems: a typo in the list name (`cores` vs `scores`) and bad indentation. If you want to avoid the temporary `score` variable on line 3, here are a few alternatives.
1) Minimal fix (append the converted input directly)
```
scores = []
for i in range(1, 6):
scores.append(float(input(f"Test {i}: ")))
```
2) Using a list comprehension (compact)
```
scores = [float(input(f"Test {i}: ")) for i in range(1, 6)]
```
3) If you prefer using map (less common for prompted input)
```
def prompt(i):
return float(input(f"Test {i}: "))
scores = list(map(prompt, range(1, 6)))
```
All three produce the same list of five floats. Choose (1) for clarity, (2) for conciseness.
1) Minimal fix (append the converted input directly)
```
scores = []
for i in range(1, 6):
scores.append(float(input(f"Test {i}: ")))
```
2) Using a list comprehension (compact)
```
scores = [float(input(f"Test {i}: ")) for i in range(1, 6)]
```
3) If you prefer using map (less common for prompted input)
```
def prompt(i):
return float(input(f"Test {i}: "))
scores = list(map(prompt, range(1, 6)))
```
All three produce the same list of five floats. Choose (1) for clarity, (2) for conciseness.
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.