while True:
hh=input('enter hours: ')
if hh == 'done':
break
try:
h=float(hh)
except:
print('please enter numeric input!')
continue
rr=input('enter rate: ')
if rr == 'done':
break
try:
r=float(rr)
except:
print('please enter a numeric input!')
continue
if h<=40:
p=h*r
else:
x=h-40
xr=r*1.5
p=40*r+x*xr
print(p)
print('thank you for using this code')
Asked
Active
Viewed 35 times
0

Hichem
- 1
- 1
-
2Turn the relevant section of the code into a function. – 9769953 Jul 18 '21 at 17:46
-
2You know if you enter an invalid value for the second input, it takes you back to the first input? is that intentional? – khelwood Jul 18 '21 at 17:46
-
2Look for the common sections of your code and create a function from that. Feed in anything that is custom like the prompt string and return the collected value, etc. – LhasaDad Jul 18 '21 at 17:47