Loading...
Loading...
Loading...
Marks arrive as text on one line, separated by spaces. Ignore values that are not whole numbers. Print the average of the valid marks with 2 decimal places.
If there are no valid marks, print No valid marks.
No valid marks.Example 1
Input
80 abc 90
Output
85.00
Average of 80 and 90.
Example 2
Input
x y
Output
No valid marks
No valid mark.
Try the problem first. Open one hint at a time.
Keep the valid marks in a list, and skip each bad value with ValueError.
After the loop, dividing by the list length raises ZeroDivisionError when the list is empty. Catch it.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor