[Tutor] Odds and even exercise

Shashwat Anand anand.shashwat at gmail.com
Sat Mar 27 14:24:13 CET 2010


On Sat, Mar 27, 2010 at 6:25 PM, TJ Dack <teejmd at gmail.com> wrote:

> Hi, just started python at Uni and think i am in for a rough ride with zero
> prior experience in programming.
> Anyway my problem that i can't fix my self after googling.
>
> The exercise is to generate a list of odd numbers between 1-100 and the
> same for even numbers.
>
> So far this is what i have CODE: SELECT ALL<http://python-forum.org/pythonforum/viewtopic.php?f=3&t=17610#> #A
> way to display numbers 1 - 100
> numbers = range(100)
>

Are you sure it displays 1 - 100. ?

>  #A way to display all odd numbers
> odd = numbers[::2]
>

Are you sure this shows odd :-/ ?
Had you read 'range' documentation ?


>  #A way to display all even numbers
>
>
> I can't find a way to easily list the even numbers, i really need a easier
> way to find answers my self but using the help docs in idle didn't get me
> far, any tips that you guys have when you come across something you can't
> solve?
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100327/6af53f95/attachment.html>


More information about the Tutor mailing list