dimanche 14 janvier 2018

Attempting to check if a list isn't empty AND some other condition within the same if statement

The easiest way to explain this is to show a simple example:

x = [0]

f = 4
if (x) & (f < 6):
    print("yes")

The idea is simple, check if a list contains any content and if some other variable is less than some number.

The solution yields the following error and I'm not entirely sure what the solution is.

TypeError: unsupported operand type(s) for &: 'list' and 'bool'

Aucun commentaire:

Enregistrer un commentaire