[python] coloured background on text not being coloured when i print to console

Problem description:
when i print to the terminal in python and i want to print text with a coloured background, for some reason it no longer colours the background, it works fine when i print something like “abc” however, when i print two spaces (" ") with coloured background, the background is not coloured.

this is very sad because a project i was working on to use the console and the print() statement to display graphics no longer works on replit.

Expected behavior:
the text " " should have a coloured background

Actual behavior:
the text does not get a coloured background

Steps to reproduce:
print some spaces (" “) with coloured background using f”\033[48;2;{r};{g};{b}m{char}"

problem appears on all devices and browsers i tried it with

Can you please send us a link to the Repl?

1 Like

Hey @19natkla! Welcome to the community!

The reason why it is not showing the background color is because there is some checking of text to see if there is unnecessary spaces in the string (probably to reduce the amount of resources needed to print to the console).

You can use the unicode character \u00a0 after the spaces to stop that from happening.

Why did replit change this?

I have already stated the reason here, though I’m not too sure if it is the main factor why.

Hey @19natkla!

Thank you for reporting this. I was able to reproduce the issue and have sent it to the team. I will follow up once I have an update.

1 Like

this does sort of solve the problem however, when i print the Unicode characters it breaks sometimes and displays a bit of jumbled up escape code and some characters that cant be displayed, i ran into this same problem in my original version of the project that used the big block Unicode characters instead of a coloured background.

heres a picture

also some added info about the jumbled up characters:
the Unicode only breaks when it becomes coloured
using regular escape codes that dont use full rbg works fine with Unicode.

What about \u200b? Does it work?

Also could you send one of your console logs if you don’t mind.

no longer works, again.

Can you send me the link to the Repl that you’re using to test this issue?

Friendly bump. Can you send me your Repl link?