Embellishing plot
Title
Question
plot(x,sin(x),'b--,linewidth=3)
File "<ipython-input-61-43923530a9ca>", line 1
plot(x,sin(x),'b--,linewidth=3)
^
SyntaxError: EOL while scanning string literal
Why it is showing error with statement ?
Python-3.4.3 Embellishing-a-plot 01-02 min 0-10 sec
Answers:
plot(x, sin(x), 'b--',linewidth=3)
An EOL ( End of Line ) while <a href="http://net-informations.com/python/err/eol.htm" target="" title="">scanning string literal</a> error indicates that the Python interpreter expected a particular character or set of characters to have occurred in a specific line of code, but that those characters were not found before the end of the line . This results in Python stopping the program execution and throwing a syntax error . Reasons:
Missing quotes
Strings spanning multiple lines
Strings can't normally span multiple lines. If you don't want the string to appear on multiple lines but you want to initialize it on multiple lines (so you can read it more easily), you can "escape" the newline by putting a backslash before the newline. If you want it to appear on multiple lines, you can use triple quotes around the string. Python is particularly prone to this type of error, since Python ends statements with newlines/line breaks , whereas most other programming languages have a character such as a semicolon (:wink: , which means that other programming languages work more easily with multi-line statements out of the box.
Login to add comment