Skip to content

Instantly share code, notes, and snippets.

@icarovirtual
Last active February 26, 2021 13:15
Show Gist options
  • Save icarovirtual/2fc09914e9d932a73de5b4c2fa3e7a28 to your computer and use it in GitHub Desktop.
Save icarovirtual/2fc09914e9d932a73de5b4c2fa3e7a28 to your computer and use it in GitHub Desktop.
guard clauses: good example
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
@AcidUK
Copy link

AcidUK commented Feb 25, 2021

I believe you've forgotten the not keyword in all but the first if statement

@icarovirtual
Copy link
Author

icarovirtual commented Feb 26, 2021

I believe you've forgotten the not keyword in all but the first if statement

@AcideUK Thank you for the keen eye on this, fixed the code :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment