I'm doing a project whereby a user has to input the value. The loop should end if the user key in the value of more than 300 for 3 times. If the user key in a value lesser than 300, a warning message should be prompted. And another criteria is that I need to allow the user to get out of the loop if the user do not meet the condition above. For now, I tried to do by using the list but my code doesn't seem to count the number of inputs.
list1 = list()
counter = 1
while counter <= 3:
ask = float(input("Please enter each of the value: "))
while ask != "":
list1.append(str(ask))
ask = float(input("Please enter each of the value: "))
if ask >= 50:
counter += 1
else:
print("Value must be more than 300. If you do not meet the criteria, please press 'enter'. ")
print(list1)
The following code is my original code which doesn't take into account of the minimum input value.
counter = 1
while counter <= 3:
ask = float(input("Please enter each of the value: "))
if ask >= 50:
counter += 1
else:
print("Value must be more than 300 ")
I would appreciate if anyone of you can help me out.
Aucun commentaire:
Enregistrer un commentaire