samedi 25 mai 2019

Invalid syntax on colon

I'm writing up a program involving speed limit and whatnot with while and if statements. I'm tryna make it so that after outputting the result, it asks if I want to redo the program with a while loop.

I heard that occurs if I have one too many brackets or an open bracket. All my brackets were fine.

ques1 = int(input('What speed is the car travelling? '))
check = ques1

running = True
while running == True:
    if 0 <= check <= 50:
        print('You are clear.')

    if 51 <= check <= 60:
        print('10 demerit points')

    if 61 <= check <= 70:
        print('20 demerit points')

    if 71 <= check <= 80:
        print('30 demerit points')

    if 81 <= check <= 90:
        print('50 demerit points')

    if 91 <= check <= 1000:
        print("100 demerit points")


    dasques = input('Do you want to try again? y/n '):
        if dasques == ('n'):
            running = False


Hoping to get : 50 demerit points Do you want to try again? y/n

but I'm getting "invalid syntax" with the colon behind: [ dasques = input('Do you want to try again? y/n '):] highlighted in red.

Aucun commentaire:

Enregistrer un commentaire