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

27th Apr 2024, 12:25 AM
Austin Mccoy
4 Réponses
+ 4
Austin Mccoy it appears Bob_Li actually answered your question as a comment in your code.
27th Apr 2024, 2:34 AM
BroFar
BroFar - avatar
+ 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
27th Apr 2024, 2:42 AM
Bob_Li
Bob_Li - avatar
+ 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='')
27th Apr 2024, 3:36 AM
Bob_Li
Bob_Li - avatar
+ 1
Thank you so much for the help!
29th Apr 2024, 2:33 AM
Austin Mccoy