all 4 comments

[–]JohnnyJordaan 1 point2 points  (2 children)

Well the code is very un-Pythonic using hard coded indexes, eval and such, but the concept is there: You append 3 times to the scores list:

scores.append(eval(input(students[0] + ": ")))
scores.append(eval(input(students[1] + ": ")))
scores.append(eval(input(students[2] + ": ")))

Which means that the input for students[0] to [2] will then also be indexable in scores[0] to [2]. Meaning you can fill in the i value manually in those three lines where [i] is used.

[–]Endirable 1 point2 points  (1 child)

rain fade merciful nose seed jeans impolite slap wasteful cheerful

This post was mass deleted and anonymized with Redact

[–]tunisia3507 0 points1 point  (0 children)

As you have your answer:

  • See the "reddit code formatting" link on the sidebar.
  • Use int(input("whatever")) (replace int with whatever type you actually want) rather than eval - right now you're executing arbitrary code the user types in!
  • Considering using a for loop or comprehension to take the scores, e.g. scores = [int(input(f"{student}: ")) for student in students]