dimanche 11 septembre 2016

Python wont choose between 2 if options

I am coding a python tic tac toe program. I have put two 'if' functions for it to choose from and it chooses from user input. But my problem is that python runs both choices.

Heres the code:

import sys print ('One or two players?') player_amount = input() if player_amount == ('One') or ('one') or ('1') or ('1.)'): print ('One player') print ('Easy, medium or hard') difficulty = input() if difficulty == ('easy') or ('Easy') or ('1') or ('1.)') or ('1)'): print ('Easy mode') print ('You have first move') print ('|1|2|3|') print ('-------') print ('|4|5|6|') print ('-------') print ('|7|8|9|') move1 = input() if move1 == ('One') or ('one') or ('1') or ('1.)'): print ('|O|2|3|') print ('-------') print ('|4|X|6|') print ('-------') print ('|7|8|9|') move2 = input() if move2 == ('2') or ('Two') or ('two') or ('2.)'): print ('|O|O|X|') print ('-------') print ('|4|X|6|') print ('-------') print ('|7|8|9|') move3 = input()

                            if move3 == ('4') or ('4.)') or ('four') or ('Four'):
                                    print ('|O|O|X|')
                                    print ('-------')
                                    print ('|O|X|6|')
                                    print ('-------')
                                    print ('|X|8|9|')
                                    print ('I win')
                                    sys.exit

                            if move3 == ('7') or ('7.)') or ('Seven') or ('seven'):
                                    print ('|0|0|X|')
                                    print ('-------')
                                    print ('|X|X|6|')
                                    print ('-------')
                                    print ('|O|8|9|')
                                    move4 = input()
                                    if move4 == ('6') or ('6.)') or ('six') or ('Six'):
                                            print ('|O|O|X|')
                                            print ('-------')
                                            print ('|X|X|O|')
                                            print ('-------')
                                            print ('|O|X|9|')
                                            print ('Draw')
                                            sys.exit

Aucun commentaire:

Enregistrer un commentaire