+ 3

What is the wrong here ?

It keeps saying that there is an error in line 8 (x> 40) https://code.sololearn.com/c3k72T1Mje5H/?ref=app

1st Jun 2017, 1:59 PM
Shimaa
Shimaa - avatar
5 Answers
+ 7
@ shima what dayve is trying to say is 1) you have two inp variable it means : inp = raw_input("Enter hours:") hours = float(inp) inp = raw_input("Enter rate:") rate = float(inp) is more like you are reassigning the value of input to inp , though there is nothing wrong with this as you have assigned that value to the hours variable but its not usually a good act these is what i mean inp = something hours = inp = something then you reassigned inp again to store another-thing inp = another-thing rate = inp= another-thing so you are still on track its just that if you want to run your code on code play ground then your "raw_input" as to be "input" cause code playground only supports python 3 and raw_input is a python 2 syntax it doesn't work on python 3, so you have to change that from raw_input to input, 2) your line 8 is not well indented you seem to have indented the is conditional statement : x = int(hours) if x > 40: rate = rate *1,5 pay = hours *rate you would agree with me that " if x> 40:", should have started the line like this x = int(hours) if x > 40: rate = rate *1,5 pay = hours *rate and your else is missing its semicolon ":" in front of it you had "else" instead of "else :" so please fix this and your program should run fine i have also written it for you on my code playground this is the link https://code.sololearn.com/cu6UpR3sW5PW/#py hopefully this helps you. your rate = rate * 1.5 not "1,5" cause the interpreter would see this as a sequence of numbers since you've got two inputs if you would be using code playground then enter the two inputs on different lines as instructed good luck
1st Jun 2017, 3:21 PM
John Emma
John Emma - avatar
+ 21
# Corrected code : hours = float(input("Enter hours:")) rate = float(input("Enter rate:")) x = int(hours) if x > 40: rate = rate *1,5 pay = hours *rate print ("overtime",pay) else : pay = hours * rate print ("no over time", pay) # Input two numbers only. 1 input doesn't work in your code :)
1st Jun 2017, 2:05 PM
Dev
Dev - avatar
+ 5
Can't understand :/
1st Jun 2017, 2:11 PM
Shimaa
Shimaa - avatar
+ 5
it worked out 😃😃 so the problem was at spaces and python 2, 3 syntax ^^ @john Emma @dayve Thanks a lot for help ^^
1st Jun 2017, 4:02 PM
Shimaa
Shimaa - avatar
+ 3
It is always best to go with the latest up date. IDLE brings you new features.
2nd Jun 2017, 12:15 AM
👑 Prometheus 🇾🇬
👑 Prometheus 🇾🇬 - avatar