extracting numbers with decimal places from a string

Store Makhzan store0a at gmail.com
Sun Jan 11 14:31:04 EST 2015


I have this script which can calculate the total of numbers given in a string
---- script -----
total = 0
for c in '0123456789':
 total += int(c)
print total
---- script -----
How should I modify this script to find the total of if the numbers given in the string form have decimal places? That is, how do I need to modify this line:
----- script -----
for c in '1.32, 5.32, 4.4, 3.78':
----- script -----
to find the total of these given numbers.


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /