'How to rewrite a variable that's dependant on two variables?

Hi, I need to code the following problem:

"If an employee has been working in the company for more than a year, they'll be elegible for 7 days of vacations for each year worked in the company. Otherwise, he'll be elegible for just 2 days. Also, if the employee works for more than 10 extra hours a week, they'll be elegible for 2 more vacation days for each 10 hours."

So far, I have the following code but when I do the final math, it won't give the exact result I should be getting, so I don't know if there's a way to solve it. Also, would it be possible to rewrite this code using elif and boolean expressions?

vacations = 0 
print("Enter Employee Experience in the company") 
years = int(input("Years : ")) 
for i in range(years+1):
    if years < 1:
        vacations = vacations + 2
    else:
        vacations = vacations + 7
        years = years - 1


ex_hours = int(input("Extra Hours Worked : ")) 
while(ex_hours >= 10 ):
    vacations = vacations + 2
    ex_hours = ex_hours -10

print("The Employee is eligible for ",vacations," days vacation")


Solution 1:[1]

You don't need the loops at all. Just use a single calculation for each step.

vacations = 0 
print("Enter Employee Experience in the company") 
years = int(input("Years : ")) 
if years > 1:
    vacations = years * 7
else:
    vacations = 2

ex_hours = int(input("Extra Hours Worked : "))
vacations = vacations + (ex_hours // 10) * 2

print("The Employee is eligible for ",vacations," days vacation")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 John Gordon