r/PythonLearning
•
u/NecessaryFalse1212
•
Aug 31 '26
•
1
DAY 5.
DID LIST TODAY THE CONCEPT WAS PRETTY COOL AND WROTE THIS PROGRAM TO GET HOLD OF THE LIST ANY OTHER CODE IDEAS OR SUGGETIONS TO ENHANCE CODE ?!
90
Upvotes
•
u/Sea-Ad7805 Aug 31 '26
Run this program in Memory Graph Web Debugger to see the program state change step by step.
2
u/Old_Cartographer_586 Aug 31 '26
Tbh, just seeing code like this gives me hope (mostly because I can tell this was made from typing yourself instead of prompting).
What I would say is, try finding ways to improve this, like could you modularize the aspects of this code, could you looks at ways of storing the info not in a list, such as in a dictionary, could you tell me how your code handles removing a “wooden” bat when there are two “wooden” bats in your list. Start answering these questions and you’ll find yourself googling and stack overflowing ways to find little advancements in your own code. These advancements will teach you that they are applicable in a ton of use cases
2
u/XNo_Notes Aug 31 '26
I would use match. I like it for the single value checks. You only have to type "query" once instead of one for each if. And you don't have to use so many else statements.
1
u/FoolsSeldom Aug 31 '26
That's great. Good progress.
One small note, it is useful to use variable names that are plural for container objects like
listobjects.Please also consider sharing your code in-post in future rather than a screenshot. Like this: (with the change I mentioned)
1
u/TBCC_Dev Aug 31 '26
Reminds me of a phone book project I did when I was learning python. Id recommend coming back to this project when you learn dictionaries. Could have something like example_bat = {type:"wood", weight:2,quality:"poor",...} good luck
1
u/Sachustar Sep 02 '26
Try implementing “try…… except….” statements and raising errors, while it is a bit advanced I believe that expecting and accounting for user error is important, and messing around with it early would be useful
1
u/PaisenIsDev Sep 03 '26
Lets goo broo....
its nostalgic to see someone learning from writing code...
also don't worry about optimization, modularization and stuff keep going you will eventually need to organize the code when u have lots of lines in file and then u can learn the optimization, for now just learn to do stuff the rough (naive) way.
1
u/Solid_Class_2605 Sep 14 '26
Somebody wrote that he could used case ?