Answer to Question #266961 in Python for rahul

Question #266961

If you are trying to print a string, what happens if you leave out one of the quotation marks or both and why?


1
Expert's answer
2021-11-16T18:37:11-0500

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.




Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS