title: How do I separate this into two files?
body: <p>This works altogether, however doesn't when they are inside separate files, like so:
  main.py</p>
  <pre><code>from write import *
  
  def write():
      global text
      text = &quot;this is a test&quot;
      colour()
  
  write()
  </code></pre>
  <p>colour.py</p>
  <pre><code>import sys
  from time import sleep
  
  blue = '\033[0;34m'
  
  def colour():
      for char in text:
          sleep(0.05)
          sys.stdout.write(blue)
          sys.stdout.write(char)
          sys.stdout.flush()
      sleep(0.5)
  </code></pre>
  <p>Error is as follows:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;main.py&quot;, line 8, in &lt;module&gt;
      write()
    File &quot;main.py&quot;, line 6, in write
      colour()
    File &quot;/home/runner/Function-Test/colour.py&quot;, line 7, in colour
      for char in text:
  NameError: name 'text' is not defined
  </code></pre>