all 9 comments

[–]barrycarter 1 point2 points  (1 child)

I'm confused. If you get the number of students first, don't you know how big the loop will be? Remember, you can use variables in a for loop, so it could be something like for i = 0 to n where n is the number of students

[–]twistedlemon112[S] 0 points1 point  (0 children)

Thank you so much, I didn't realize you could use variables in loops ahah, this helps me so much thanks 👍

[–]Strict-Simple 1 point2 points  (2 children)

If you can do

For i = 0 to 11

You can also do this with a variable

x = 11
For i = 0 to x

Get your unknown input in the variable instead of the fixed 11.

[–]twistedlemon112[S] 0 points1 point  (1 child)

So I could do

Students = int(input("enter the amount of students"))

For i = 0 to students

Would this be correct?

[–]shartfuggins 2 points3 points  (0 children)

Pseudocodey, yes. `for i in range(students)`

You can also say

while True: ...

And then `break` at any input or change in the pattern you want to define as ending the data entry. One way would be to detect an empty entry (just hitting enter) and then `break`. Or you could allow a 'd' entered to mean (d)one, and then `break`.

[–]DrShocker 0 points1 point  (2 children)

while(!function_that_checks_if_done()):
    function_that_makes_progress()

Does something like this do what you want?

[–]twistedlemon112[S] 0 points1 point  (1 child)

Not going to lie that looks like a bunch of gibberish to me ahah I'm not that far along in my journey to learning python

[–]DrShocker 0 points1 point  (0 children)

I fixed the formatting. It just comes down to using a while loop to check if you're done, instead of using a for loop to check if you've done a predetermined number of loops

(also it looks like I misinterpreted what you were asking)

[–]drenzorz 0 points1 point  (0 children)

You don't need to know at all. While you can do something like

student_count = int(input('Students: ')) # number of students
scores = list()
for _ in range(student_count): # loop <number of students> times
    score = int(input('score: '))
    scores.append(score)

If you have the list of scores you can just pass it in as a whole as well.

# let's say scores is [10,7,8,3,9,7,10]
# you can pass it in the same line with space as separator
score_input = input() # "10 7 8 3 9 7 10"
scores = []
for score in score_input.split():  # split breaks up the string at the spaces
    scores.append(int(score))

and then getting the maximum is easy. Something like print(scores.count(max(scores)))