0

When I call my player function it shows an error: Exception has occurred: NameError name 'player' is not defined.

def main():
    player='x'

    def switchplayer():
        global player

        if player == 'x':  # use double equal because its boolean       
              player = 'O'
        else:
              player = 'x'


if __name__ == "__main__":
    main()
MatsLindh
  • 49,529
  • 4
  • 53
  • 84
HesamHashemi
  • 949
  • 1
  • 3
  • 8

0 Answers0