+ 1

Is there anyone know how to use (while loop) who's willing to help me solve this problem i dont understand it

Input her budget and shopping locations: "Bowling Green" or "Nashville" with tax rate 6% and 9% respectively. if input value for her budget is large than 300, then print "over budget" ; Otherwise, continue. Keep generating a random price for an item, if Emily still has money left, then continue to consider the next item. Otherwse, she finishes her shopping. Print the total number of items she has bought and print the average price of the items she has bought.

1st Oct 2021, 7:33 PM
Salehe Akili
Salehe Akili - avatar
6 Respostas
+ 1
Please show your attempt
1st Oct 2021, 8:03 PM
Kamil Hamid
Kamil Hamid - avatar
+ 1
how do I tag a question?
1st Oct 2021, 8:28 PM
Salehe Akili
Salehe Akili - avatar
+ 1
from random import: def main(): total= 0 numberOfchair=0 while 1: chairsValue= numberOfChair+=1 total=total+chairValue elif total>=215 and total<=300 print("I mam done") break else: print("More than 300, is broken") break print("total number of chir",) I am stuck
1st Oct 2021, 9:43 PM
Salehe Akili
Salehe Akili - avatar
0
I am afraid to say there are several problems in your code: Firstly, you do not need the first line, as not only have you put an unneeded colon, but have not specified which function from random you wish to import. Secondly, the while loop, if it supposed to be infinite, with the breaks you have, should be while True: Thirdly, I am not sure if this has just gone onto the next line, but make sure lines 4 and 5 are joined by meaning (i.e. you have not pressed the key to make it go onto a new line). Fourthly, the elif statement should end in a colon, and be succeding (following) an if statement like so: if total<225: pass And lastly, for the last line, make sure chair is spelt correctly ;) as well as the variable name total going after the comma. Hope this uas helped, and don’t be discouraged, coding isn’t easy! Happy coding!
2nd Oct 2021, 6:45 AM
Kamil Hamid
Kamil Hamid - avatar