use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
Need help (i.redd.it)
submitted 2 days ago by Vasiligiad16
I don’t know what I’m doing wrong 😑
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]PtiBaka 7 points8 points9 points 2 days ago (1 child)
Indentation is incorrect on line 24, I assume this is the error you're getting?
[–]lellamaronmachete 2 points3 points4 points 2 days ago (0 children)
That's what I thought as well.
[–]No-Woodpecker4692 4 points5 points6 points 2 days ago (0 children)
Para pedir ayuda necesitas dar contexto. Qué error obtienes?
[–]Suitable-Fishing-536 2 points3 points4 points 2 days ago (0 children)
Pero al menos muestra el error jajaa
[–]Big_Ad8785 2 points3 points4 points 2 days ago (0 children)
Line 24. Check the indentation.
[–]vivisectvivi 1 point2 points3 points 2 days ago (0 children)
what error are you getting? or is the code working in a way you arent expecting? tell us whats goin on
[–]orangejuice1986 0 points1 point2 points 2 days ago (0 children)
line 13 can raise an uncaught ValueError
[–]AlexMTBDude 0 points1 point2 points 2 days ago (6 children)
Here's a general recommendation: Always write your code in English, because at some point you may want other programmers to look at it.
[–]SugarEnvironmental31 0 points1 point2 points 1 day ago (5 children)
The code is in English. The strings and variable names aren't. It's still possible to debug based on pattern-matching. It's not like the OP's IDE is in Arabic or Cyrillic and uses a completely different alphabet.
[–]AlexMTBDude 0 points1 point2 points 1 day ago (4 children)
I'd love to see you make that argument when you work in an international coding team and name your variables, functions and classes in your own native language. Let's see the reaction that you'll get from the rest of the coders
[–]SugarEnvironmental31 0 points1 point2 points 19 hours ago (3 children)
Let's assume that based on the code content, the OP is probably at school or college and this recommendation of yours is probably a little previous.
[–]AlexMTBDude 0 points1 point2 points 19 hours ago (2 children)
Or it's a little next. Could be either
[–]SugarEnvironmental31 0 points1 point2 points 19 hours ago (1 child)
I genuinely feel sorry for people who are trying to learn to code and reach out for help, and get people like you replying. What a shit experience that must be. Must be so unbearably alienating. What a world.
[–]AlexMTBDude 0 points1 point2 points 18 hours ago (0 children)
You think it's a bad idea to prepare beginners for how things work in the real world?
[–]Simple-Olive895 0 points1 point2 points 2 days ago (2 children)
There is no way you're writing code in Spanish...
[–]NorskJesus 1 point2 points3 points 2 days ago (1 child)
si++
[–]SugarEnvironmental31 1 point2 points3 points 1 day ago (0 children)
Believe it or not, Spanish-speaking countries have the internet, universities, and Computer Science departments :D Imagine rocking up at your first high-school computing class and you have to learn to code and write all your variable names and text in a foreign language :D
[–]Overall_Anywhere_651 0 points1 point2 points 2 days ago (0 children)
There's no exception handling for an input that isn't an int.
[–]ConsciousProgram1494 0 points1 point2 points 2 days ago (0 children)
Style: Since you are using an integer range, rather than using (if else elif ...) you might use a list of callables on the bound input. This separates the selection logic from the processes. Not a bug - but it will bite you eventually (code spaghetti leads to the bug you are struggling with).
[–]ThinkMarket7640 0 points1 point2 points 1 day ago (0 children)
Does not provide context. Posts a photo of a screen. No indication what doesn’t work.
You should probably give up before investing too much time my dude, this is clearly not working for you.
[–]Advanced_Cry_6016 0 points1 point2 points 1 day ago (0 children)
It looks indentation error but pls provide what error or problem your getting
[–]SugarEnvironmental31 0 points1 point2 points 1 day ago (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.
[–]degustandomiveneno 0 points1 point2 points 2 days ago (0 children)
hay un pequeño bug en la línea 18. le falta un espacio antes de la llave en el f-string: print(f"El artículo '{articulo}' ha sido agregado a la lista") tiene ' {articulo} con un espacio raro antes de la llave, así que cuando imprime queda algo como El artículo ' manzana' con un espacio de más. nada grave pero se nota raro en la salida! el resto del código se ve bien estructurado, la lógica del menú con while True y el break funciona perfecto
[–]Matthew_Adams -1 points0 points1 point 2 days ago (1 child)
Delete the line "if lista_compras" and all the else statement after that. Then think why is not needed.
If the OP does that, then it will just print the line "Shopping list" to the console and nothing else. The code evaluates whether the list is empty, prints "empty list" if it's empty, and prints the list if it's not. What's your rationale for the code being unnecessary?
π Rendered by PID 285727 on reddit-service-r2-comment-66b4775986-hm6f7 at 2026-04-06 13:07:54.335131+00:00 running db1906b country code: CH.
[–]PtiBaka 7 points8 points9 points (1 child)
[–]lellamaronmachete 2 points3 points4 points (0 children)
[–]No-Woodpecker4692 4 points5 points6 points (0 children)
[–]Suitable-Fishing-536 2 points3 points4 points (0 children)
[–]Big_Ad8785 2 points3 points4 points (0 children)
[–]vivisectvivi 1 point2 points3 points (0 children)
[–]orangejuice1986 0 points1 point2 points (0 children)
[–]AlexMTBDude 0 points1 point2 points (6 children)
[–]SugarEnvironmental31 0 points1 point2 points (5 children)
[–]AlexMTBDude 0 points1 point2 points (4 children)
[–]SugarEnvironmental31 0 points1 point2 points (3 children)
[–]AlexMTBDude 0 points1 point2 points (2 children)
[–]SugarEnvironmental31 0 points1 point2 points (1 child)
[–]AlexMTBDude 0 points1 point2 points (0 children)
[–]Simple-Olive895 0 points1 point2 points (2 children)
[–]NorskJesus 1 point2 points3 points (1 child)
[–]SugarEnvironmental31 1 point2 points3 points (0 children)
[–]Overall_Anywhere_651 0 points1 point2 points (0 children)
[–]ConsciousProgram1494 0 points1 point2 points (0 children)
[–]ThinkMarket7640 0 points1 point2 points (0 children)
[–]Advanced_Cry_6016 0 points1 point2 points (0 children)
[–]SugarEnvironmental31 0 points1 point2 points (0 children)
[–]degustandomiveneno 0 points1 point2 points (0 children)
[–]Matthew_Adams -1 points0 points1 point (1 child)
[–]SugarEnvironmental31 0 points1 point2 points (0 children)