python Syntax Error EOL while scanning string literal

0 votes
I have the above-mentioned error in s1="some very long string............"

What is wrong here?
Feb 4, 2022 in Python by Nandini
• 5,480 points
1,252 views

1 answer to this question.

0 votes

There are many ways to deal with this:

  1. Use r before the string to avoid any errors, this will parse the string without giving errors.

For example:

 s= r”some very long string …”
  1. Using escape characters \ to use it in strings add one more \. This means \\ without and space in between

  2. Can use triple quotation marks, be careful to use only three quotation marks.
       " " " a very long string ......            
     ....multiple lines
            " " "

Hope this helps.

answered Feb 5, 2022 by Dev
• 6,000 points

Related Questions In Python

0 votes
0 answers

python: SyntaxError: EOL while scanning string literal

I have the above-mentioned error in s1="some ...READ MORE

Dec 22, 2022 in Python by erzan
• 630 points
455 views
+2 votes
2 answers

Error while printing hello world in python.

You must be trying this command in ...READ MORE

answered Mar 31, 2018 in Python by GandalfDwhite
• 1,320 points
6,494 views
+2 votes
10 answers

How to fix this? ValueError: invalid literal for int() with base 10 error in Python

The following are totally acceptable in python: passing ...READ MORE

answered Nov 16, 2018 in Python by Nymeria
• 3,560 points
409,379 views
0 votes
2 answers

Python UnboundLocalError error while executing script

Inside your function when you say word=word+1, ...READ MORE

answered May 22, 2020 in Python by Ibrahim Nezar
• 140 points
1,984 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,467 views
0 votes
1 answer
0 votes
2 answers

What's the difference between %s and %d in Python string formatting?

The reason is that they are using ...READ MORE

answered Feb 8, 2022 in Python by Rahul
• 9,680 points
22,932 views
0 votes
1 answer

Converting integer to string in Python

In order to convert an object to string ...READ MORE

answered Feb 11, 2022 in Python by Dev
• 6,000 points
607 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP