Hello, Winni!
I think some parts of your code work, but in the rules of the task the user must input how many people are standing at the line for the lift.
I don't know if I will explain this right, but I will try.
For example the user puts that 6 people are in the line waiting.
The user needs to input their masses. I will write some for example. 1st 97kg, 2nd 83kg, 3rd 103kg, 4th 76kg, 5th 89kg and the 6th 98kg.
The task requires, that I need to use the most weight in the lift that doesn't exceed 500kg. If I were to add the first 5 peoples mass it would be 448kg, but if I were to replace the 4th person with the 6th then the mass would be 470kg. And in this case the 4th person would be thrown out.
If the mass of the 6 people would be under 500 then the lift would just go, but since the mass exceeds the 500kg, I need to choose those people, whos combined mass will be either 500kg or the closest to 500kg
It's a really complicated task for me, and I don't know how to do this exactly.
I understand, if you don't want to try to write it again with these requirements, but I am thankful for your first attemp.