A user reported this bug: "The program crashes with ZeroDivisionError when the line is empty." Fix it. For an empty line, print no numbers; otherwise print the average of the numbers with two digits after the point.
Input
One line with up to 100 whole numbers separated by spaces. The line may be empty.
Output
The average, like 6.50, or no numbers.
Examples
Example 1 · Input
4 8 6
Expected output
6.00
Example 2 · Input
Expected output
no numbers
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
Reproduce it first: run the starter with an empty line as input.
Hint 2
input().split() gives an empty list for an empty line.
Hint 3
Check for an empty list before dividing.
Solution
Show one correct solution (try it yourself first)
numbers = [int(x) for x in input().split()]
if not numbers:
print("no numbers")
else:
average = sum(numbers) / len(numbers)
print(f"{average:.2f}")