+ 1

Why is this a syntax error

Im trying to do this exercise to make a calculator that calculates your pay when you input hours and your rate. If there is more than 40 hours then the rate is * 1.5. With this code i get a syntax error on the number 40. Also when i run the program it tells that that it looks like i need some input and to separate my input to separate lines... Hours = (input("Enter your hours\n")) Rate = (input("Enter your rate\n")) Hours =float(Hours) Rate =float(Rate) Pay = Hours * Rate if Hours > 40 Rate = Rate * 1.5 print (Pay)

20th Nov 2018, 7:18 PM
Adam
3 Antworten
+ 6
You should add a colon after 40 :) Also, if you are trying to run the script on SoloLearn, you have to provide both input values right away, separated by a newline. So like this: 50 8 This is because the script is not run within the application but on a remote server. And it has to have all the necessary input right away, at once.
20th Nov 2018, 9:18 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
Missing ":" at the end of your if ?
20th Nov 2018, 9:18 PM
Geoffrey L
Geoffrey L - avatar
0
Thank you!
20th Nov 2018, 9:28 PM
Adam