Skip to content

Instantly share code, notes, and snippets.

@Jestre
Created September 4, 2013 23:00
Show Gist options
  • Save Jestre/6443965 to your computer and use it in GitHub Desktop.
Save Jestre/6443965 to your computer and use it in GitHub Desktop.
Take 2 on lucpet's function
def shit_happens(num):
""" (num)
Take 2 on lucpet's function.
This one takes a num, adds it to itself, and then compares
it to various static numbers.
>>> shit_happens(3)
woo hoo
>>> shit_happens(2)
yay
>>> shit_happens(1)
WTF
"""
sum = num + num
if sum >= 5:
#if shit happens, do this
print('woo hoo')
elif sum >= 4:
#if that last didn't happen, do this
print('yay')
else:
"""
If none of that happened, do this
N.B. No need for any comparison here, if there was
no match in the first two, this will fire anyway. If
you do want this to fire if (and only if) 2+2<= 3, then
use a second elif instead of an else, e.g.
elif 2 + 2 <= 3:
"""
print('WTF')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment