I need to write a program that calculates the users pay. The part I'm stuck on is where I have to ask for the amount of hours the user worked for each day of the week (which is repeated depending on how many weeks they specified). This is what I have so far:
daysofweek = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
day = 0
while day < weeks: #user specified variable above 0
for i in range(len(daysofweek)):
while True:
daysofweek[i] = input("Enter the number of hours for week 1 " + daysofweek[i] + ": ")
try:
hours = float(daysofweek[i])
if hours < 0 or hours > 24:
print("Invalid: Enter a number between 0 and 24")
continue
break
except ValueError:
print("Invalid: Enter a number between 0 and 24")
day = day + 1
Sorry for the wall of code (some of it is probably irrelevant to my issue). So basically this iterates through the list well the first week but then the day names are replaced with the numbers that are entered. Plus I'm not sure how to store these variables that are entered so I can calculate the pay afterwards. Sorry if this is asking too much, just completely stuck. Thanks!
daysofweek[i] = input('x')replaces values indaysofweek. What did you intended to do?