+ 2
How to return code to top line if user makes input less than 40. I tried like this but it doesn't work. Thank you all in advance
hour=float(input("how many hours:")) rate=float(input("rate per hour")) def work(hour,rate): if hour >= 40: print("overtime") nor = hour*rate pvm = (hour - 40.0) * (rate * 0.5) o = nor + pvm print(f'Normal shift:{nor:"^9},Overtime:{pvm:*<9},Alltogether:{o}') if rate<40: print("input more than 40") work(hour,rate) else: exit() x=work(hour,rate) print(x)
3 Respostas
+ 2
I tried before "if rate <40" but it doesn't work still
+ 1
This will call again the same method with same values infinitely if the input is less than 40. You need ask input again when input is less than 40.
After taking input you can call the function. Or call function, then take input... So add input() lines in function at begining. Or add it in if part when rate < 40..
You are not returing any value from function so x will be 'none'.
Try again, if not work then share code link by saving it...
Hope it helps
0
Can you share update code link here...?
Before means it should be again executable so with in the function...