I am studying Python and using Google colab as an IDE. Using 033[m does not end the colorization. Can anyone help?

Asked

Viewed 44 times

-2

I’m learning Python and using Google colab.
So I tried.

print('\033[31mOlá Mundo!\033[m')
print('Olá Mundo!')

What happens is that the \033[m does not contain colorization
and the next line and all other answers also appear colored.

I tested on another platform and it worked.

Thank you for your attention.

1 answer

1


To return colors to normal, simply execute the following command:

print('\033[31mOlá Mundo!\033[0m')
print('Olá Mundo!')

Note that in my solution I added the following command at the end of the string.

`\033[0m`

I just added one 0 (zero) at the end of the command.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.