Hell when I first read it I thought he did the right thing. Damn! What can I say? I AM a programmer... I guess the simplest algorithm is not always the best.
#!/usr/bin/env python
from SuperMarkets import check_out, find_markets, inventory
def run_errand(milk, eggs):
shopping_cart = []
if 'milk' in inventory and 'eggs' in inventory:
shopping_cart.append(milk * 6)
elif 'milk' in inventory and 'eggs' not in inventory:
shopping_cart.append(milk)
else:
print 'Store has no milk. Try another.'
find_markets()
check_out(shopping_cart)
if __name__ == '__main__':
run_errand(milk='milk', eggs='eggs')
What the wife should have said to her programmer husband:
#!/usr/bin/env python
from SuperMarkets import check_out, find_markets, inventory
def run_errand(milk, eggs):
shopping_cart = []
if 'milk' in inventory and 'eggs' in inventory:
shopping_cart.append(milk + eggs)
elif 'milk' in inventory and 'eggs' not in inventory:
shopping_cart.append(milk)
elif 'eggs' in inventory and 'milk' not in inventory:
shopping_cart.append(eggs)
print 'Buy eggs, then go to another store for milk.'
find_markets()
else:
print 'Store has no eggs or milk. Try another.'
find_markets()
check_out(shopping_cart)
if __name__ == '__main__':
run_errand(milk='milk', eggs='eggs' * 6)
Coders here should understand the difference in the two above snippets.
#!/usr/bin/env python
from SuperMarkets import check_out, find_markets, inventory
def run_errand(milk, eggs):
shopping_cart = []
if 'milk' in inventory and 'eggs' in inventory:
shopping_cart.append(milk * 6)
elif 'milk' in inventory and 'eggs' not in inventory:
shopping_cart.append(milk)
else:
print 'Store has no milk. Try another.'
find_markets()
check_out(shopping_cart)
if __name__ == '__main__':
run_errand(milk='milk', eggs='eggs')
What the wife should have said to her programmer husband:
#!/usr/bin/env python
from SuperMarkets import check_out, find_markets, inventory
def run_errand(milk, eggs):
shopping_cart = []
if 'milk' in inventory and 'eggs' in inventory:
shopping_cart.append(milk + eggs)
elif 'milk' in inventory and 'eggs' not in inventory:
shopping_cart.append(milk)
elif 'eggs' in inventory and 'milk' not in inventory:
shopping_cart.append(eggs)
print 'Buy eggs, then go to another store for milk.'
find_markets()
else:
print 'Store has no eggs or milk. Try another.'
find_markets()
check_out(shopping_cart)
if __name__ == '__main__':
run_errand(milk='milk', eggs='eggs' * 6)
Coders here should understand the difference in the two above snippets.
LOL. I am nowhere near a programmer nor did I understand the joke from that viewpoint. However...I still got the joke for some reason. I guess it's what happens around here every day whenever there's something left up to my mate - even when things are listed in writing.