[Tutor] Odd & Even lists

Cameron Simpson cs at cskk.id.au
Sat May 30 19:15:13 EDT 2020


On 30May2020 17:40, Alan Gauld <alan.gauld at yahoo.co.uk> wrote:
>On 30/05/2020 15:06, Mary Knauth via Tutor wrote:
>> We are passing in a list of numbers. You need to create 2 new lists 
>> in your chart, then
>>
>> put all odd numbers in one list
>> put all even numbers in the other list
>> output the odd list first, the even list second
>> Current code I am running:
[...]
>> for i in range(numbers)
>
>range doesn't take a list of numbers as an argument, it expects a
>start,stop, step sequence of integers. I suspect what you really want
>here is the simpler
>
>for i in numbers:

I think it is worth mentioning the enmerate() function here, a great way 
to get a sequence of (index,value) pairs from a list of values. This 
makes Mary's test easier to do.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Tutor mailing list