When the hex colour passed to print() is not in the list in colors.py, the script fails with error UnboundLocalError: local variable 'code' referenced before assignment, since the line which sets code never runs as it doesn't find the passed hex colour in the colours.py file.
I'd suggest adding a statement which checks if code hasn't been assigned after it has looped through colours, and can approximate a colour in some way if necessary.
When the hex colour passed to print() is not in the list in colors.py, the script fails with error
UnboundLocalError: local variable 'code' referenced before assignment, since the line which setscodenever runs as it doesn't find the passed hex colour in the colours.py file.I'd suggest adding a statement which checks if code hasn't been assigned after it has looped through
colours, and can approximate a colour in some way if necessary.