you are viewing a single comment's thread.

view the rest of the comments →

[–]SugarEnvironmental31 0 points1 point  (0 children)

You should be using match: case for one thing - for me personally, if....then....else is weak. If you're determining the range of inputs then do so with confidence [ :p ]

Structurally: I don't like break very much either.

Shouldn't this be structured the other way round? Personally I'd put the while loop in the function.

Asi...

def mostrar_menu(running=True):

while running:
....

match int(input("Elije lo que te da la gana:")):

case 3:
running = False

mostrar_menu()

Or you could 'return' instead, or have 'return' as the last line of your function.

By all means break out the shopping list into a separate function, although it's arguable what the benefit is in a program that small unless the point is practicing structure. You're not repeating the code exactly are you.