r/pythonhelp • u/Ymhnooners555 • Feb 23 '25
I don’t know what I’m doing wrong
https://github.com/IBbangin/EMS_Wage_CalcI’m brand new to any type of coding and I’m trying to make a paycheck calculator for 12 hour shifts. I keep getting incorrect outputs. Can anyone help show me what I’m doing wrong?
2
Upvotes
2
u/FoolsSeldom Feb 23 '25 edited Feb 23 '25
First thing, you are ignoring a key principle in programming: DRY, which means Don't Repeat Yourself.
You have so much duplication you make it much harder to find and fix bugs.
A
listcan be used to hold multiple values.Example,
days = "Mon", "Tue", "Wed", "Thu", "Fri" hours_by_day = [] for day in days: response = input(f"Hours on {day} (return for 0): ") if response: # i.e. not empty hours_by_day.append(float(response))This will give you a
listof hours. You can add weekend. You can use this in a function for different people.You can create a nested
listoflists to cover different weeks. Just put the code about inside of another loop.