dimanche 13 janvier 2019

Python nested List comprehension with Dependent Conditional

I am trying to put this conditional clause into my list comp "arr".

arr = [[(i*n+j) for i in range(n)] for j in range(n)]

with

if ( 2*i<=j+i+1<=n+1 and i>0)

as the conditional. I tried putting this:

-with a else statement in a ternary at the front: "" , yet this produces unwanted elements in the array.

-as is after my for statements (i, j, and even tried both)

Any Ideas on how to get this to compute without adding to much complexity?

Aucun commentaire:

Enregistrer un commentaire