본문 바로가기
codeacademy

10. A Day at the Supermarket / Stocking Out

by 밝게웃다 2017. 3. 28.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
shopping_list = ["banana""orange""apple"]
 
stock = {
    "banana"6,
    "apple"0,
    "orange"32,
    "pear"15
}
    
prices = {
    "banana"4,
    "apple"2,
    "orange"1.5,
    "pear"3
}
 
def compute_bill(food):
    total = 0
    for n in food:
        if stock[n] >0 :
            total += prices[n]
            stock[n] -=1
    return total
    
 
 
 
cs


'codeacademy' 카테고리의 다른 글

13. Battle ship!  (0) 2017.03.28
11. Student Becomes the Teacher  (0) 2017.03.28
8. Taking a Vacation / Hey, You Never Know!  (0) 2017.03.28
7. Functions / Practice Makes Perfect  (0) 2017.03.28
파이썬 숫자 맞추기 게임(Guess My Number)  (0) 2017.03.28

댓글