Hello @shrood ,
If you are trying to find the sum of numbers entered by the user then your code is correct.
The error is because the IDE you are using might be taking all the input first and then executed your sciprt. so first enter all the inputs required and then exectute your script.
For example:
5
4
1
3
2
5
15
Here n=5 and sum=15.
Tips: Try with diffrent IDE like pycharm(it will takes user input one at a time)
If you want to execute your script use this https://www.tutorialspoint.com/execute_python_online.php(Note: first give the value n and all the values entered by the user in stdin and in main.py paste your script)
Hope it helps!!
Thank you!!