> odd =1
>>>>while odd <=100:
>         if (odd%2)==1:
>                 print odd
>         odd = odd + 1
> -------------------------------------------------------------------------------------------------
> I get a list of the odd numbers from 1 to 99. But now if I wanted to add 
> those number together (i.e. 1 + 3 +5 + 7 etc.), what line of coding should I 
> include?

Hint: create an additional variable called oddsum to tally it up. Add
each number to that. There are several approaches but this fits into
your existing program the easiest, I think.


Alan

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to