title: TicTacToe project in Python 2: I am trying to avoid using global variables and return variables instead
body: <p>I am working on a project, and I have no idea how to avoid using global variables. I have a list of functions that perform bits and pieces but I am not able to pass variables between them!</p>
  
  <p>Here is my current code:</p>
  
  <p>===================</p>
  
  <pre><code>def player_names_input():
      global player_A_name,player_B_name
      player_A_name = raw_input("Please enter name for Player A    :   ")
      player_B_name = raw_input("Please enter name for Player B    :   ")
  
  def coin_flip():
      global player_A_name,player_B_name,start_player,end_player,game_state
      game_state = "running"
      import random
      print "\nFlipping a coin to see who starts first..."
      random_int = random.randint(0, 1)
      if random_int == 0:
          coin = 'Heads'
          start_player = player_A_name
          end_player = player_B_name
      else:
          coin = 'Tails'
          start_player = player_B_name
          end_player = player_A_name
      print '\nCoin flip --&gt; ',coin
      print '\nStarting player --&gt; ',start_player
      print '\nStarting player gets "X"'
  
  player_names_input()
  coin_flip()
  </code></pre>
  
  <p>Here is my failed attempt to use return instead of global:</p>
  
  <p>=========================================================</p>
  
  <pre><code>def player_names_input():
      player_A_name = raw_input("Please enter name for Player A    :   ")
      player_B_name = raw_input("Please enter name for Player B    :   ")
      return player_A_name,player_B_name
  
  def coin_flip(player_A_name,player_B_name):
      game_state = "running"
      import random
      print "\nFlipping a coin to see who starts first..."
      random_int = random.randint(0, 1)
      if random_int == 0:
          coin = 'Heads'
          start_player = player_A_name
          end_player = player_B_name
      else:
          coin = 'Tails'
          start_player = player_B_name
          end_player = player_A_name
      print '\nCoin flip --&gt; ',coin
      print '\nStarting player --&gt; ',start_player
      print '\nStarting player gets "X"'
  
  player_names_input()
  coin_flip(player_A_name,player_B_name)
  </code></pre>
  
  <p>1- Please help make my second code run, I really wanna avoid global variables as everyone recommends.
  2- Please critique my code, I am in the beginning and I am trying to learn writing good code (not just code). How bad is my attempt?</p>