#๐Ÿ”’ colored words on idle?

34 messages ยท Page 1 of 1 (latest)

kindred trail
#

I am very new to coding and know basically nothing, when using IDLE to edit my code, sometimes when pasting things i have stored in notepad, some of the words become colored and creates errors in my code, why is this?

hazy burrowBOT
#

@kindred trail

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

potent shore
#

does the code run fine?

kindred trail
#

no it errors out starting at the first colored line, if i backspace and manually type the entire paragraph or section, the color goes away and code runs

#

if i backspace one letter from colored words, when i complete the word again, color comes back

spring pulsar
#

The text is being considered as Python code by the highlighter. and is colored because that's a keyword, and r's to the end of the line is colored because r' starts a raw string.

kindred trail
#

how do i resolve this? i have the exact formatting for other text earilier in the code that does not do this, it only happens when i paste from notepad

empty venture
#

can you paste your code as text instead of a screenshot

kindred trail
#

i have 15 or so of these, the first one is ok and i had the other 14 written in a notepad and pasted into IDLE, it creates the wierd colors and errors out

#

SyntaxError: unterminated string literal (detected at line 37)

#

i know its messy guys, its still getting worked on!

empty venture
#

you likely didn't terminate the string before it

kindred trail
#

Its terminated

empty venture
#

it doesn't look so in the screenshot

#

you'd have to provide more context to be sure

kindred trail
#

SyntaxError: unterminated string literal (detected at line 44)

#

all i did was backspace one letter from each colored word, the error moved down to next lines

#

no more colored text

#

no error regarding those lines anymore

empty venture
#

the colored text and the syntax error are two different things

kindred trail
#

the colored text is causing the syntax error

empty venture
#

no it isn't

kindred trail
#

how do you figure? i remove the colored text and the error goes away

empty venture
#

the colored text is your IDE trying to highlight python syntax, it probably thinks the text in the string literal is python code as a result of the previous syntax error

#

i can't be more specific unless you provide your actual code

kindred trail
#

i was forgetting a the 3 "s it needed after the first entry

#

i have been using python for 4 days, its so much fun

#

thanks!

empty venture
#

np

hazy burrowBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.