I am trying to understand that bit of code:
s = list()
r = string()
# actual bit of code:
print(s and 'ERROR' or r or 'EMPTY')
What this does:
- if
s
is not an empty list, then you must print'ERROR'
- else if
r
is not an empty string you must printr
- else print
'EMPTY'
I am now trying to understand why this works, and more widely how you can use logical operators in expressions, like in this example.