# Checking multiple things with an if else statement

Is there a way to check multiple things in an if statement? I have a program in which I want to check if the degree of the lowest term of a polynomial is equal the degree of the lowest term of any polynomial in another list of polynomials. Essentially, what I have so far is:

def W(i):
d=set()
for w in range(0,d[i]):
if ListBasis[i][w].polynomial().ord() notequal ListBasis[i-1][y].polynomial.ord():
else:
return d


And what I would like to have is

def W(i):
F=set()
for w in range(0,d[i]):
if for y in range(0,d[i]) ListBasis[i][w].polynomial().ord() notequal ListBasis[i-1][y].polynomial.ord():
else:
return F


Clearly this is not the correct syntax for this, but I do not know what is.

edit retag close merge delete

Sort by ยป oldest newest most voted

Python's all() and any() functions are your friends here:

if all(ListBasis[i][w].polynomial().ord() != ListBasis[i-1][y].polynomial.ord() for w in range(d[i])):

more

## Stats

Seen: 209 times

Last updated: Jan 30 '22