I'm getting a ''Expected ":" Pylance error and i dont know what i did wrong

Question:

This is the code. I know that the "question" variables are useless, but that’s how i like to do it.
I was supposed to make a pay computation program that asks for input about hours worked and rate of pay and pay 1.5 times the rate for hours worked above 40.


question = ('How many hours have you worked this month ?n')
question1 = ("What's the rate of pay ?n")

hrs  = input(question)
rate = input(question1)

if hrs > 40 :

    pay = (hrs-40) * (float(rate) * 1.5)
    print ('Your payment is ', pay + 'dollars.')


else hrs < 40 :
      
    pay = hrs*rate
    print ('Your payment is ', pay + 'dollars.')

I tried to nest it a different way and googled python debugger, but nothing helped. Please tell me how to fix this error and where my mistake is so that i can learn. Thank you !

Asked By: NewbieCoder1234

||

Answers:

Hope following code will help you.

question = ('How many hours have you worked this month ?n')
question1 = ("What's the rate of pay ?n")

hrs  = input(question)
rate = input(question1)

hrs = int(hrs)
rate = int(rate)

if hrs > 40 :
    pay = (hrs-40) * (float(rate) * 1.5)
    print ('Your payment is ', str(pay) + 'dollars.')

elif hrs < 40:
    pay = hrs*rate
    print ('Your payment is ', str(pay) + 'dollars.')

keep in mind that, input() will always return string datatype, and you have to convert into the int for arithmatic operation,

Wherenver you try to concat string, then you have to convert int to string

Answered By: Pandurang Choudekar
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.