Run

Add numbers from input in Python

Read several numbers on one line and add them up. Press Run to try it, then change the code and run it again.

main.py

numbers = [int(x) for x in input("Enter numbers separated by spaces: ").split()]
print("Sum:", sum(numbers))
print("Average:", sum(numbers) / len(numbers))
Output

Press Run to see the output.

More Python examples

Open the full Python online compiler →