lundi 19 octobre 2020

if not statement explanation

this code was provided in an answer that I found, but there was no explanation. I'm wondering why the 'not message' need to be included in order for this to work?

def first_and_last(message):
    if not message or message[0] == message[-1]:
        return True
    else:
        return False

Aucun commentaire:

Enregistrer un commentaire