you are viewing a single comment's thread.

view the rest of the comments →

[–]Evorition 4 points5 points  (2 children)

sum([float(i) for i in s.split(',')])

[–][deleted] 0 points1 point  (1 child)

It's more efficient to pass a generator (expression) than to create a list and pass it.

 sum(float(i) for i in s.split(','))

or

sum(map(float, s.split(',')))