Write a Python program that finds the sum of all numbers in a list. The list will be provided as a single line input with space-separated numbers.
Example 1:
Input: 1 2 3 4 5
Output: 15
Example 2:
Input: 10 20 30 40
Output: 100
You can split the input string into a list of numbers. Then use a for loop to iterate through the list and calculate the sum.
nums = list(map(int, input().split()))
total = 0
for num in nums:
total += num
print(total)
NOTEOwing to browser caching, any code input into the Trinket IDE might carry over across page refreshes or when transitioning between different questions. To commence with a clean slate, either click on the 'Reset Button' found within the IDE's Hamburger icon (☰) menu or resort to using Chrome's Incognito Mode.