Write a function called safe_average(numbers) that returns the average of a list
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
Problem
Write a function called safe_average(numbers) that returns the average of a list. Handle the edge case: if the list is empty, return 0 instead of dividing by zero. Print the result of calling it on scores, then on empty.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.