What mistake am I making with syntax?

I’m new to python and have to make a code to calculate pay/what type of work you did (part-time, overtime, etc.) My code is this:

hours=int(input("How many hours did you work?"))
rate=int(input("What is your hourly rate?"))
bonusr=int(input("What is your bonus rate?"))
normaltotal=rate*hours
bonus=rate*bonusr*(hours-40)
pay+bonus=normaltotal+bonus 
if hours<32:
  print("You worked part-time")
  print(normaltotal)
elif hours>32 and <=40:
  print("You worked Full-Time")
  print(normaltotal)
elif hours>40:
  print("You worked over-time")
  print(pay+bonus)

Im getting a syntax error for “elif hours>32 and <=40” and I’m not sure why

Would appreciate any help, Thanks!

Answer

When you use the ‘and’ logic, it will operate the clauses separately. To use it properly, you need to state ‘hours’ twice:

hours=int(input("How many hours did you work?"))
rate=int(input("What is your hourly rate?"))
bonusr=int(input("What is your bonus rate?"))
normaltotal=rate*hours
bonus=rate*bonusr*(hours-40)
pay+bonus=normaltotal+bonus 
if hours<32:
  print("You worked part-time")
  print(normaltotal)
elif hours>32 and hours<=40:
  print("You worked Full-Time")
  print(normaltotal)
elif hours>40:
  print("You worked over-time")
  print(pay+bonus)

Leave a Reply

Your email address will not be published. Required fields are marked *