Implement p0 tutorial.
This commit is contained in:
@@ -32,12 +32,15 @@ def buyLotsOfFruit(orderList):
|
||||
|
||||
Returns cost of order
|
||||
"""
|
||||
totalCost = 0.0
|
||||
"*** YOUR CODE HERE ***"
|
||||
return totalCost
|
||||
|
||||
try:
|
||||
return sum([fruitPrices[fruit] * quantity
|
||||
for fruit, quantity in orderList])
|
||||
except KeyError:
|
||||
print("Unexpected fruit!")
|
||||
return None
|
||||
|
||||
# Main Method
|
||||
if __name__ == '__main__':
|
||||
"This code runs when you invoke the script from the command line"
|
||||
orderList = [ ('apples', 2.0), ('pears', 3.0), ('limes', 4.0) ]
|
||||
print 'Cost of', orderList, 'is', buyLotsOfFruit(orderList)
|
||||
print('Cost of', orderList, 'is', buyLotsOfFruit(orderList))
|
||||
|
||||
Reference in New Issue
Block a user