If you are trying to print a string, what happens if you leave out one of the quotation marks or both and why?
For example:
>>> print (Hello")
SyntaxError: EOL while scanning string literal
A string literal is where you specify the contents of a string
Here a string literal would be Hello and print would be a variable pointing to the string.
String literals can use single or double-quotes.
>>> print (Hello)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
print (Hello)
NameError: name 'Hello' is not defined
>>>
Interpreter thinks this is a global value and it is showing that variable was not defined.
Comments
Leave a comment