def foo(x):
a,b = (0,"")
for i in x:
if i != " ":
b+=i
else:
print ("this is b",b)
a = a + int(b)
print ("this is a",a)
b = ""
print ("final a ",a)


this should help you solve it. figure a way to add the last number. if any 
troubles ask again.
Thanks [😊]

________________________________
From: Tutor <tutor-bounces+itetteh34=hotmail....@python.org> on behalf of Bob 
Gailer <bgai...@gmail.com>
Sent: Wednesday, October 12, 2016 2:26 PM
To: LQ Soh
Cc: tutor@python.org
Subject: Re: [Tutor] Adding numbers within a string

On Oct 12, 2016 4:09 AM, "LQ Soh" <sohlq...@gmail.com> wrote:
>
> 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

def sum_numbers(x):
    for x in [1]:
        print(23)

Your instructor will probably be displeased with that answer, but it meets
the requirements.

It would be nice if our teachers could models writing good requirements.

What do you think a good requirement statement would be?
_______________________________________________
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
Tutor Info Page - mail.python.org Mailing 
Lists<https://mail.python.org/mailman/listinfo/tutor>
mail.python.org
This list is for folks who want to ask questions regarding how to learn 
computer programming with the Python language and its standard library.



_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
Tutor Info Page - mail.python.org Mailing 
Lists<https://mail.python.org/mailman/listinfo/tutor>
mail.python.org
This list is for folks who want to ask questions regarding how to learn 
computer programming with the Python language and its standard library.



_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
  • [Tutor] Addin... LQ Soh
    • Re: [Tut... Alan Gauld via Tutor
    • Re: [Tut... Bob Gailer
      • Re: ... isaac tetteh
    • Re: [Tut... hell gates
      • Re: ... D . V . N . Sarma డి . వి . ఎన్ . శర్మ
        • ... D . V . N . Sarma డి . వి . ఎన్ . శర్మ
          • ... Alan Gauld via Tutor
            • ... D . V . N . Sarma డి . వి . ఎన్ . శర్మ
              • ... Danny Yoo

Reply via email to