Mix of valid and invalid items
Input
safe_divide_list([10, '20', 'bad', 5], 5)
Output
[2.0, 4.0, 1.0]
10 -> 2.0, '20' -> 4.0 (converted), 'bad' skipped, 5 -> 1.0
Full lesson preview
Safely process items in a list, skipping those that cause exceptions or can't be converted.
Problem statement
Task
Examples
Input
safe_divide_list([10, '20', 'bad', 5], 5)
Output
[2.0, 4.0, 1.0]
10 -> 2.0, '20' -> 4.0 (converted), 'bad' skipped, 5 -> 1.0
Input format
Output format
Constraints
Samples
Input
safe_divide_list([' 15 ', None, 'x'], 3)
Output
[5.0]
' 15 ' converts to 15 then divided by 3 -> 5.0; None and 'x' are skipped.