dimanche 27 septembre 2015

Ending an argument if given the wrong answer

I am creating a text based game maze type game and I cannot figure out how to end the argument if given the wrong answer. Any help is greatly appreciated. A little chunk of my code will be posted to understand what I mean. If the player types in the number 2 instead of 1 for the the first input and the game reads it as wrong i want the game to end making them start over

EDIT: I forgot to clarify I am writing in Python

def chosenTurn1():
turn = ''
while turn!='1' and turn!= '2':
  print('You are approaching your first turn')
  print('Which way will you go?')
  turn = input()
  print()
return turn

def checkTurn1(chosenTurn):
 print('the walls are shaking')
 time.sleep(1)
 print('the floor starts to break')
 time.sleep(1)
 print('.........................')
 time.sleep(2)
 friendlyTurn = (1)
 print()
if chosenTurn == str(1):
 print('You are on the right track, lets keep going')
 print()
else:
 print('You fell in a pit')
 print()
return main


def main():

 turnNumber = chosenTurn1()

 checkTurn1(turnNumber)

main()

Aucun commentaire:

Enregistrer un commentaire