I have a bunch of loops for calculations that I want to perform. I am calculating the average value of 4 lines in a file. However, I want to loop this calculation of an entire file with hundreds of numbers.
i.e.
2
5
3
7
3
1
4
6
2
4
3
2
...
would give
4.25
3.5
2.75
...
Can someone recommend a solution?
Your problem appears to be a general programming problem, not really a Python problem. You have a problem, you understand what needs to happen, but are having trouble coming up with a program.
Think about it in small steps. What do you really want to happen?
You assume the file is all single numbers on a line, that's ok. You assume the file will have a multiple of 4 lines, also ok. But you should probably also think about what happens if that's not true.
Which part is giving you trouble? Which one of these steps cannot be easily found in the Python documentation or other StackOverflow questions?
Just remember to break down a task in small, simple steps that together solve the problem. Understand the problem before you start writing code.