File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ money = 20
2
+ items = {'apple' : 2 , 'banana' : 4 , 'orange' : 6 }
3
+ for item_name in items :
4
+ print ('--------------------------------------------------' )
5
+ print ('You have ' + str (money ) + ' dollars in your wallet' )
6
+ print ('Each ' + item_name + ' costs ' + str (items [item_name ]) + ' dollars' )
7
+
8
+ input_count = input ('How many ' + item_name + 's do you want?:' )
9
+ print ('You will buy ' + input_count + ' ' + item_name + 's' )
10
+
11
+ count = int (input_count )
12
+ total_price = items [item_name ] * count
13
+ print ('The total price is ' + str (total_price ) + ' dollars' )
14
+
15
+ if money >= total_price :
16
+ print ('You have bought ' + input_count + ' ' + item_name + 's' )
17
+ money -= total_price
18
+
19
+ if money == 0 :
20
+ print ('Your wallet is now empty' )
21
+ break
22
+ else :
23
+ print ('You do not have enough money' )
24
+ print ('You cannot buy that many ' + item_name + 's' )
25
+ print ('The balance is ' + str (money ) + ' dollars' )
You can’t perform that action at this time.
0 commit comments