First, from the 3rd layer loop directly out of all loops
Break_flag =Falsecount=0 whileBreak_flag = =False:Print("-First Floor") whileBreak_flag = =False:Print("Second Floor") whileBreak_flag = =False:count+ = 1ifCount > 10: Break_flag=TruePrint("Third Floor")Print("Keep going ...")With Break_flag
#Break_flag = FalseCount =0 whileCount < 3: Print("-First Floor") whileCount < 3: Print("Second Floor") whileCount <= 10: Count+ = 1#if Count >: #Break_flag = True Print("Third Floor")Print("Keep going ...")without Break_flag
Second, the shopping cart procedure
Goods_list = [['Iphone7', 5800],['Coffee', 30],[' Book', 99],['Bike', 199],['Vivi X9', 2499]]#Product ListShopping_cart = []#User Shopping Cart listsalary = Int (input ('Input your Salary:'))#User Salarym =Salaryk=0 whileTrue:index=0 forGoodsinchGoods_list:#print a list of items Print(index,goods) Index+ = 1Choice= Input ('>>>:'). Strip ()ifchoice.isdigit (): Choice=int (choice)ifChoice >= 0 andChoice <Len (goods_list): Goods=Goods_list[choice]ifGoods[1] <= Salary:#determine if the user has enough money to pay for the selected itemshopping_cart.append (goods) salary-= Goods[1] Print('ADD Goods'+str (Goods[0]) +'into shopping cart! Your Current Balance:'+Str (salary))Else: Print('No enough money! The price is:'+str (Goods[1]) +'! Need more:'+str (goods[1]-salary)) Else: Print('Has no this goods!') elifChoice = ='Q': Print('----------Your Shopping Cart----------') Print('ID Goods Quantity price total') forIinchRange (len (goods_list)): J=Shopping_cart.count (Goods_list[i])ifJ >0:k+ = 1PrintK'\ t', Goods_list[i][0],'\ t'J'\t\t', Goods_list[i][1],'\ t', J * Goods_list[i][1]) Print('Total Price is:', M-salary) Break Else: Print('Has no this goods')Shopping Cart Procedure
Python Basics-Small program exercises