very new to Python, and I was trying to make a tip calculator for my manager at work.
The way tips are calculated is that the percent of the day the server works, they get that percent of the tips. For example, if Server 1 works 30% of the hours that day, they receive 30% of the tips that were given that day.
I am stuck trying to figure out how to divide a number (the variable "hourNum" in the code) by each element in the array that stores the hours servers worked. This would get me a percentage of the day that the server worked.
With the code below, the math does not seem to calculate properly nor print correctly.
I have been unable to find anything similar on Stack Overflow that asks the same question unfortunately.
Attached below is the source code, the problem is in the last section titled "calculate percent of day server worked":
#get hours in the day
print('Enter how many hours were worked in the day: ')
hourNum = int(input())
#get tips for the day
print("Enter how much tips were earned (enter to the nearest whole dollar, do not use a dollar sign): ")
tipNum = int(input())
# creating an empty list
lst = []
# number of elemetns as input
serverNum = int(input("Enter number of servers that worked the day : "))
# iterating till the range
print("Enter the number of hours each server worked (in order): ")
for i in range(0, serverNum):
ele = int(input())
lst.append(ele) # adding the element
print("You entered: ", lst)
#calculate percent of day servers worked
n = 0
for i in range (0,serverNum):
print (hourNum / lst[0 + n])
n+1
Any tips or help would be much appreciated :)