Loading...
Loading...
Loading...
A form sends several values on one line, separated by spaces. Some are not numbers. Print the sum of the values that are whole numbers and ignore the others.
If there are no valid values, print 0.
Example
Input
10 abc 5 7.5 20
Output
35
Only 10, 5 and 20 count.
Try the problem first. Open one hint at a time.
Loop over the values. Put try and except inside the loop.
Skip a bad value by catching ValueError and doing nothing for it.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor