Last active
February 26, 2021 13:15
-
-
Save icarovirtual/2fc09914e9d932a73de5b4c2fa3e7a28 to your computer and use it in GitHub Desktop.
guard clauses: good example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_platypus(self): | |
# Not a platypus for everything below | |
if not self.is_mammal(): | |
return False | |
if not self.has_fur(): | |
return False | |
if not self.has_beak(): | |
return False | |
if not self.has_tail(): | |
return False | |
if not self.can_swim(): | |
return False | |
# Finally, it's a platypus! | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@AcideUK Thank you for the keen eye on this, fixed the code :)