Avatar ·

Correct line break in Python

📁 List, Advanced Python Topics, example

Please advise, there is a list with phrases, but they are long and PEP8 complains about the line length.

I break part of the phrase with the \\ character, but then it counts all the spaces.

Example:

list_of_words = [""The weather is good."",                 ""Hot dog is the best food, \\                 it would be a sure sign that it was still yummy."",                 ""The girls are beautiful."",                 ""Any text, doesn't matter, but after the backslash there is a huge \\                 distance between words. How to fix this?""]print(*list_of_words)

Output:



                    
                
Avatar ·

Try this:

# pip install emojiimport emojitext = ""???????????????????????????‍??‍??‍❤‍?‍?????✋???What a beautiful day!""new_text = ''.join(char for char in text if char not in emoji.UNICODE_EMOJI)print(new_text)# ‍‍‍‍‍What a beautiful day!

Log in to leave an answer

Blogs