hours = float(input("Enter Hours:"))
rate = float(input("Enter Rate:"))
extra = 1.5 * (rate) * (hours - 40)
try:
if hours > 40:
print "Pay: %r" % ((40) * (rate) + (extra))
else:
print "Pay: %r" % ((hours) * (rate))
except:
print "Please enter numeric value!!!"
Asked
Active
Viewed 19 times
0
-
thanks for editing :) – amr ayach Dec 04 '15 at 14:14
-
try `raw_input()` instead of `input()`, it seems that you are using Python2.x, Also, the conversion of `str` to `float` in the line: `hours = float(input("Enter Hours:"))` should be inside the `try catch` block. – ZdaR Dec 04 '15 at 14:14
-
Your `try/except` should be around the place where you cast the strings to `float`. – khelwood Dec 04 '15 at 14:15
-
wont work too value error : could not convert string into float – amr ayach Dec 04 '15 at 14:16
-
@amrayach: that's something new then. Did you actually enter a floating point string? – Martijn Pieters Dec 04 '15 at 14:18
-
thanks guys ill give it another try – amr ayach Dec 04 '15 at 14:20