'How do I separate this into two files?
This works altogether, however doesn't when they are inside separate files, like so: main.py
from write import *
def write():
global text
text = "this is a test"
colour()
write()
colour.py
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)
Error is as follows:
Traceback (most recent call last):
File "main.py", line 8, in <module>
write()
File "main.py", line 6, in write
colour()
File "/home/runner/Function-Test/colour.py", line 7, in colour
for char in text:
NameError: name 'text' is not defined
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
