The following solution to the grocery problem in CS50P provided an output that was identical to the one requested in the CS50P Grocery List problem description. It works perfectly in all three Python IDEs that I have (using Linux). Yet when using check50 I get this error:
Results for cs50/problems/2022/python/grocery generated by check50 v3.3.6
:) grocery.py exists
:( input of EOF halts program
expected exit code 0, not 1
This is my code (the indentation of "main" is wonky here but not in codespace). The error capture code is indistinguishable from a problem set where it worked without issue. I have spent an hour trying to find the issue and am at a dead end.
def main():
try:
itemlist=[]
while True:
item = input ("Your grocery item: ").strip().upper()
itemlist.append(item)
itemlist.sort()
itemdict = {i:itemlist.count(i) for i in itemlist}
except EOFError:
print()
for key in itemdict:
print(itemdict[key], key)
main()
UPDATE: I installed VSCode Desktop and ran this code with the debugger on. According to VSCode there are no errors or issues with this code. Ctrl-d works as it should and the output is identical to what is shown in the problem instructions.
I am really hoping that a CS50 staff member is monitoring this forum. This problem is no solvable for a beginner!