title: UnboundLocalError: local variable 'userOrder' referenced before assignment, however it had no error being called in a similar manner earlier
body: <p>I'm writing in python using the discord.py plugin. The very top of my code looks like this:</p>
  <pre><code>import random
  import sqlite3
  import discord
  import shuffle as shf
  import time
  import os
  
  client = discord.Client()
  
  userOrder = []
  roundOrder = []
  turnPos = 0
  joinedPlayers = 0
  maxPlayers = 0
  currentPlayer = 0
  centerPot = 0
  
  @client.event
  async def on_ready():
      print(&quot;Logged in&quot;)
      print(userOrder, roundOrder, joinedPlayers, currentPlayer + &quot;\n---&quot;)
  
  @client.event
  async def on_message(message):
      print(userOrder, roundOrder, joinedPlayers, currentPlayer)
  </code></pre>
  <p>The result when it is run is this:</p>
  <pre><code>Logged in
  [] [] 0 0
  ---
  Ignoring exception in on_message
  Traceback (most recent call last):
    File &quot;C:\Program Files (x86)\Python36-32\lib\site-packages\discord\client.py&quot;, line 333, in _run_event
      await coro(*args, **kwargs)
    File &quot;C:\Users\Willi\Desktop\Python Projects\Discord Bots\Poker Bot\Poker Game.py&quot;, line 29, in on_message
      print(userOrder, roundOrder, joinedPlayers, currentPlayer)
  UnboundLocalError: local variable 'userOrder' referenced before assignment
  </code></pre>
  <p>This confuses me because the first function on_ready() had no problem calling the global variable, whereas the second function, with the same indents and no extra code failed to call a global variable and thought I wanted a local variable.</p>