title: Name is not defined error inside a function, despite using global variable, it's being ignored | Python
body: <p>The first block of code before the <code>sendhelp()</code> function works fine, the second block of code too, but when the function executes, It gives me an <code>name 'defualt_mode' is not defined</code> error, despite using  <code>global</code>, it totally gets ignored, since when I remove it, it gives me the same error, WHAT? What I want to happen is to have it accept the default variable, but without removing the function and without manually defining it inside the function.
  What I mean by 'manually' :</p>
  <pre><code>def sendhelp():
  
      defualt_mode = True
  
          
      if defualt_mode is True:
  
          #list of accounts
          account_list = [&quot;tech.dailys&quot;, &quot;technologyhive&quot;, &quot;rising.tech&quot;, &quot;fanastic.technology&quot;, &quot;xtechnation&quot;, &quot;technology&quot;, &quot;fundamentaltech&quot;, &quot;techsector&quot;]
  </code></pre>
  <p>Also if there are any alternatives to using global that'd be awesome (without removing the <code>sendhelp()</code> function)</p>
  <pre><code>
  message_response = ['/V/M/itechexplore, bruh, fam, dawg', 'dksasadj', 'jdsjsalkd', 'kalsdn']
  
  
  for message in message_response:
  
      if '/V/M/' in message:
  
          pre_account_list= []
          multiple_account_scan_accounts = message.removeprefix(&quot;/V/M/&quot;)
          
  
          pre_account_list.append(multiple_account_scan_accounts)
          
  
          for message in pre_account_list:
              if &quot;,&quot; in message:
                  pre2_account_list = message.split(&quot;, &quot;)
          
          print(pre2_account_list)
              
          default_mode = False
  
  
      if '/V/M/R/' in message:
  
          
          default_mode = True
  
  
  
  def sendhelp():
  
      #checks if the defualt list is active
      global defualt_mode
  
          
      if defualt_mode is True:
  
          #list of accounts
          account_list = [&quot;tech.dailys&quot;, &quot;technologyhive&quot;, &quot;rising.tech&quot;, &quot;fanastic.technology&quot;, &quot;xtechnation&quot;, &quot;technology&quot;, &quot;fundamentaltech&quot;, &quot;techsector&quot;]
  
  
  
  if default_mode is True or default_mode is False:
      sendhelp()
  
  
  </code></pre>