0
Forever loop pls help
I'm trying to get this to stop looping forever and allow further inputs, any ideas? https://sololearn.com/compiler-playground/cdnze5KswXLB/?ref=app
4 Respuestas
+ 4
Austin Mccoy it appears Bob_Li actually answered your question as a comment in your code.
+ 3
Austin Mccoy
Looping inputs are not possible with Sololearn's input system. You can only submit your input once. so you can gather all your inputs into a list and work with that.
Maybe something like this:
https://sololearn.com/compiler-playground/ciDQRxQGemqU/?ref=app
+ 3
if you are not using Sololearn, here is a working looping input:
plant = ""
planttypes = ["Bulbs", "Herbs", "Greens", "Heads", "Roots", "CoverCrops"]
choices = []
print(planttypes)
while True:
plant = input("\nPlease enter a plant type or xxx to quit.\n")
if plant in ("Bulbs", "Herbs", "Greens"):
print("Start from seed outdoors in February")
choices.append(plant)
elif plant in ("Heads", "Roots"):
print("Start from seed outdoors in March")
choices.append(plant)
elif plant == "CoverCrops":
print("These can be started anytime from December to March")
choices.append(plant)
elif plant=="xxx":
print("quitting")
break
else:
print("Invalid plant type. Input a correct name or type xxx to quit")
print()
for p in planttypes:
print(f"{p:<7}", end='')
print("-"*45)
for i in range(len(planttypes)):
print(f" {choices.count(planttypes[i]):<6}", end='')
+ 1
Thank you so much for the help!