Back to Lesson
Data Type Filtering
Filter mixed list elements using isinstance() to safeguard processes.
Instructions
- Given
mixed = [42, "hello", 3.14, True, [1, 2], 55, "world"] - You want to retrieve only the integers, butis a subclass of int! You must check if the type is exactly
Trueor useintand not a boolean.isinstance - Create a list containing only elements where. Print the sum of these integers using
type(item) is int.sum()
main.py
main.py
Ctrl + Enter