Answers for "python sum numeric values in mixed list"

0

python sum numeric values in mixed list

# Python code to add only numbers in a list of characters and numbers
ini_list = [1, 2, 3, 4, 'a', 'b', 'x', 5, 'z']

res = sum(filter(lambda i: isinstance(i, int), ini_list)) # Add numbers from list

print ("Resultant sum: ", res)

# Output:
# Resultant sum: 15
Posted by: Guest on July-02-2021

Code answers related to "python sum numeric values in mixed list"

Python Answers by Framework

Browse Popular Code Answers by Language