python - Invalid Syntax - Logic Error -
can check on bit of code? i'm getting invalid syntax without explanation. needs know when input between 8-40 go through overtime_hours = 0, , when input 41-86 needs go through overtime_hours = original_hours - 40.
while original_hours < 8 or original_hours > 40: overtime_hours = 0 elif original_hours > 41 or original_hours < 86: overtime_hours = original_hours - 40
this homework assignment, , part of larger payroll program.
if want use elif
, must have if
first. also, conditions seems bad, try this:
if 8 <= original_hours <= 40: overtime_hours = 0 elif 41 <= original_hours <= 86: overtime_hours = original_hours - 40
or this:
if original_hours in range(8, 41): overtime_hours = 0 elif original_hours in range(41, 87): overtime_hours = original_hours - 40
note range(a, b)
includes a
doesn't include b
. that's why should use range(8, 40+1)
Comments
Post a Comment