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.
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!!