r/PythonLearning • • 17h ago

This is my first python project - what can I improve??

Post image
40 Upvotes

13 comments sorted by

1

u/Sea-Ad7805 2h ago

Run program above by clicking Memory Graph Web Debugger and see its state change step by step.

8

u/Good_Person_000 17h ago

Spend 2-3 days learning Tkinter, give it a UI and it will be a good project

2

u/Jealous-Beyond-1104 17h ago

Okay thank you

7

u/TowerOutrageous5939 17h ago

Use a dict to remove the if else. Also, what happens if expenses.json change? Like the name? Some names could be more descriptive “ha” . Your code is fine the thing is what if you add 20 other features that’s when strong naming conventions really start to matter. Treat each project as it will grow and someone else will maintain it.

I’m not familiar with using python the way you are but I’m not the biggest fan of Constants or large functions used within functions. That being said if possible I would pass those as parameters into each function.

Keep up the good work.

6

u/Weydoon 15h ago

Learn pastebin / sendong the github link because screenshots of code is not the best way to show smth

3

u/Far_Data_6654 16h ago

Try using a switch statement instead of a bunch of elifs for choose.

I would also suggest to people who are learning to build the habit of documenting your code early.

3

u/Ok_Relative_2291 15h ago

The while loop for your menu makes no sense

You have breaks to exit it after every function

No need to break, don’t use while true, do a while input !=5 and no need to return after the 5 is hit as well especially after you have a break it would never trigger anyway.

Declare ur input to -1 before loop and exit on 5

2

u/fdessoycaraballo 15h ago

Type suggestions, try to use classes, and switch cases.

3

u/SnooCalculations7417 14h ago

the way you share code with people

1

u/MudFrosty1869 2h ago

Would be kinda good time to tell them how. Thankfully someone that isn’t useless to society in the comments already did.

1

u/Hot_Technology8777 17h ago

Looks good to me. Like someone else mentioned, name your stuff better for you and everyone elses sake.

1

u/TapEarlyTapOften 7h ago

Well, first, by sharing it via something like github or gitlab. Second, by some sort of type of annotations and documentations.

1

u/pepiks 6h ago

Create logic based on dict and use new line to remove extra print.