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