Sorry, I did not read the conditions that split and for should not be used. regards, Sarma.
On Wed, Oct 12, 2016 at 10:20 PM, D.V.N.Sarma డి.వి.ఎన్.శర్మ <dvnsa...@gmail.com> wrote: > def string_sum(s): > total = 0 > items = s.split(" ") > for item in items: > total += int(item) > print(total) > > You can call the function as > > string_sum("10 4 5 ") > > Output will be 19. > regards, > Sarma. > > > On Wed, Oct 12, 2016 at 3:22 PM, hell gates <hellgat...@yandex.com> wrote: >> You can write your own str.split or just use while loop. >> 12.10.2016, 15:12, "LQ Soh" <sohlq...@gmail.com>: >> >> To whom it may concern, >> Can someone enlighten me as to how you can create a function such >> that sum_numbers('10 5 8'), when run, will give an answer of 23, without >> using str.split() and using a for loop >> _______________________________________________ >> Tutor maillist - [1]Tutor@python.org >> To unsubscribe or change subscription options: >> [2]https://mail.python.org/mailman/listinfo/tutor >> >> References >> >> Visible links >> 1. mailto:Tutor@python.org >> 2. https://mail.python.org/mailman/listinfo/tutor >> _______________________________________________ >> Tutor maillist - Tutor@python.org >> To unsubscribe or change subscription options: >> https://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor