#530 · Strings · Beginner · Find and fix · 30 XP · about 4 min
A quiz app saves a player's round scores as text, for example '12,7,30'. total_score(text) should return the total of the scores as a whole number. There may be spaces after the commas, and an empty string means no rounds were played, so the total is 0.
The code in the editor has a bug. For '12,7,30' it returns 12730 instead of 49.
total_score('12,7,30') # returns 49 total_score('5, 5') # returns 10 total_score('42') # returns 42 total_score('') # returns 0
First solves only, ranked by stars and then time.