dimanche 16 juin 2019

Python error: Syntax error while making game

I'm new to python and programming and I was trying to make a simple game in python. However, I can't seem to fix this syntax error on the 21st line. If anyone knows how to fix it, please help me!

import random
import sys

num = 0
badGuess = 0
gameOver = 3
randnum = random.randrange(0,5)

while num != randnum:
    print("try and guess my number!")
    num = int(input())

    if num > 5:
        print("TIP: the number is between 1 and 5")

    else:
        print("Wrong!")
        badGuess = badGuess+1
        print("You have " + badGuess + "/3 tries!"

        if badGuess >= gameOver:
            print("game over")
            sys.exit()

print("you guessed it!")

Aucun commentaire:

Enregistrer un commentaire