Ask Your Question
1

Conditional in list

asked 2021-02-13 18:55:13 +0100

Cyrille gravatar image

updated 2021-02-13 19:02:22 +0100

If this works

[1  if i<12 else (0 if 12<= i <=15 else 2) for i in range(20)]

where is my fault with

cand=["A","B","C","D"]
cond1=[[141,107],[163,85],[127,121],[132,116],[117,131],[120,128]]
cond2=[(["A","B"],"A"),(["A","C"],"A"),(["A","D"],"A"),(["B","C"],"B"),(["B","D"],"D"),(["C","D"],"D")]
zoo=[[0   if cond2[i][1]==cand[j] else ((abs(cond1[i][0]-cond1[i][1])) if cond2[i][0][0]=cand[j] or cond2[i][0][1]=cand[j]) for i in range(len(cond2))] for j in range(len(cand))]
zoo
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2021-02-13 19:06:24 +0100

Max Alekseyev gravatar image

You don't have else for the second if.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-02-13 18:55:13 +0100

Seen: 741 times

Last updated: Feb 13 '21