I would like to create a function that take a list and sum all number in the list. For instance, in the list ["a", 1.50, 2, u'week', 250, 12]
, the function will return the output 255.50
(1.50 + 2 +250 +12).
def sum(list):
sum = 0
for item in list:
if type(item) == 'a number'
sum += item
return sum
By what could I replace the line if type(item) == 'a number'
?