Hello, I am new tocoding

Hello, I am new to programming and I am using python. I have a little problem. below is me trying to use the “try” reserved words but I keep getting a taceback, that there is a problem with my line 4 - dy = float(yz). Can anybody help?

xy = input('Work Hours:')
yz = input('Rate:')
try:
	ds = float(xy)
	dy = float(yz)
except:
	print('Numbers only')
	quit()
ab = ds*dy
if ds > 40:
	print('overtime')
	otp = (ds-40) * (dy*0.5)
	mm = ab + otp
else:
	print('regular')
	mm = dy*ds
print('pay',mm)

Okay, thank you, It works fine. I just foundout I was using an old file

I’m glad the code worked for you!


I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

Thank you, Jeremy. Would make sure to do that the next time

1 Like