What is the expected output of the following code?

What is the expected output of the following code?

x = ”’

print(len(x))
A . 1
B. 2
C. The code is erroneous.
D. 0

Answer: A

Explanation:

Topics: len() escaping

Try it yourself:

print(len(”’)) # 1

The backslash is the character to escape another character.

Here the backslash escapes the following single quote character.

Together they are one character.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments