Home › Forums › Decaffeinated Coffee › Computer Programmer › Reply To: Computer Programmer
April 29, 2011 3:30 pm at 3:30 pm
#763817
Clairvoyant
Member
What the wife actually said:
.
#!/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)