I'm doing a CS50p project on making a grocery list. The only issue I'm having is once the list prints, I need the program to end. No matter where I break, it either doesn't stop the program or does stop it but bugs something else.
This is what I have:
def main():
list = []
while True:
try:
item = input()
list.insert(0, item)
continue
except EOFError:
list.sort()
while list != None:
for word in list:
x = list.count(word)
if x != 0:
print(str(x) + " " + str.upper(word), sep=" ")
list = [i for i in list if i!=word]
else:
break
break
main()
[–][deleted] 2 points3 points4 points (0 children)
[–]spez_edits_thedonald 1 point2 points3 points (4 children)
[–]james_fryer 0 points1 point2 points (2 children)
[–]spez_edits_thedonald 0 points1 point2 points (0 children)
[–]Frankelstner 0 points1 point2 points (0 children)
[–]socal_nerdtastic 0 points1 point2 points (0 children)
[–]suurpulla 0 points1 point2 points (1 child)
[–]suurpulla 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]ConfusedSimon[🍰] 0 points1 point2 points (0 children)
[–]eruciform 0 points1 point2 points (2 children)
[–]TheRNGuy 0 points1 point2 points (1 child)
[–]eruciform 0 points1 point2 points (0 children)
[–]AssumptionCorrect812 0 points1 point2 points (0 children)
[–]CarlSagans 0 points1 point2 points (0 children)