The existing code was, presumably, provided as a model that you are expected to understand in order to see some basic tools available to you, so that you can then use the same kinds of tools to solve the problem. So, let’s try to do that analysis. After all, programming is about solving problems, and to learn programming (and it seems very clear that there is someone else - the person or organization that gave you the code - who is trying to teach you programming) we must develop problem-solving skill.
In your own words: outside of programming - with pencil and paper - how is an average calculated? Do you see how this corresponds to the code that was given to you? (Hint: do you see how it looks at each value from the data, one at a time? What does it do with the values as they are encountered? What does it do after it’s finished looking at all the values?
Now that we see how the code is used to implement those steps, we have to work backwards: figure out the new steps what we want to use to solve the new problem, and then figure out what code will implement the new steps.
Step by step, how would you find the maximum, with pencil and paper? Try to describe a step-by-step process. (Hint: it should probably involve looking at each value, one at a time. What would make sense to do with each value, as you encounter it?) Following the model of the existing code for the average, can you envision what the code for the maximum might look like?
Let’s also consider your own initial analysis:
Looking at the existing code, can you see the part where it determines “the floats” that should be compared? Given two float values, do you understand how to compare them, and how to “replace another variable with the higher float”? Where exactly are you getting stuck with this?
My best guess: you are seeing that there is only one new value that you get each time through the loop, but you know that two values are needed to compare to each other. In this case, you just need to think more clearly about what you should be comparing the new value to. (Hint: you already mentioned it.) (Hint: try actually setting up the problem and trying to solve it by hand with pencil and paper. Make sure that you only allow yourself to look at one of the input values at a time. I am confident that you will naturally do the right thing, and only need to notice what you are doing.)