Hi there,
I have followed a tutorial, but i don't manage to solve this error :
Thanks to the people who will help me :)
I have followed a tutorial, but i don't manage to solve this error :
Error:"cedmo@cedmo-HP-EliteBook-8770w:~$ ./DragonRdm.py
File "./DragonRdm.py", line 31
if nombre == random.randint(1,10):
^
SyntaxError: invalid syntax"
My script (i'm using Vim) is written like this :#!/usr/bin/env python # -*-coding:Latin-1 -* import random print("Tu te trouves dans une pièce obscure d'un mystérieux chateau.") print("Tu dois choisir entre quatre portes.") choixJoueur = input("Choisis 1, 2, 3 ou 4...") if choixJoueur == "1": print("Tu as trouvé un trésor. Tu es riche !") print("BRAVO, TU AS GAGNE !") elif choixJoueur == "2": print("La porte s'ouvre et un ogre affamé te donne un coup de massue.") print("GAME OVER, TU AS PERDU !") elif choixJoueur == "3": print("Il y a un dragon endormi dans cette pièce.") print("Tu peux soit :") print("1) Essayer de voler l'or du dragon.") print("2) Essayer d'échapper au dragon.") choixDragon = input("Entre 1 ou 2...") if choixDragon == "1": print("Le dragon se réveille et te mange. Il te trouve délicieux.") print("GAME OVER, TU AS PERDU !") elif choixDragon == "2": print("Tu échappes au dragon, tu sors du château et tu revois la lumière du jour.") print("BRAVO, TU AS GAGNE.") else: print("Désolé, tu n'as pas entré 1 ou 2 !") elif choixJoueur == "4": print("Tu entres dans une pièce où se trouve un sphinx.") print("Il te demande de deviner à quel nombre il pense, entre 1 et 10.") nombre = int(input("Quel chiffre choisis-tu ?") if nombre == random.randint(1,10): print("Déçu, le sphinx émet un sifflement. Tu as deviné juste.") print("Il doit te laisser partir.") print("BRAVO, TU AS GAGNE !") else: print("Le sphinx te dit que tu n'as pas deviné le bon chiffre.") print("Tu es désormais son prisonnier à jamais.") print("GAME OVER, TU AS PERDU !") else: print("Désolé, tu n'as pas entré 1, 2, 3 ou 4 !") print("Lance à nouveau le jeu pour réessayer.")I don't understand where the syntax of the 31st line is wrong.
Thanks to the people who will help me :)