+ 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.
6 Respostas
+ 1
Please show your attempt
+ 1
how do I tag a question?
+ 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
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!