'Python array conditions

I wanna know how do I initialize a 2d array where the first row will have all even from 0-10, and 2nd row will have all odd from 11-20, so and so until in column 10 we will have 91-100 of all odd? thanks!



Solution 1:[1]

 ls = [];
 for i in range(10):
    temp = [];
    for j in range(i*10, (i+1)*10):
        if j%2==i%2:
            temp.append(j);
    ls.append(temp);

This should probably do it;

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hiten Tandon