Computer Science

What will following code print?

str1 = '''Hell
o'''
str2 = '''Hell\
o'''
print(len(str1) > len(str2))

Python

Python Data Handling

44 Likes

Answer

This code will print:

True

len(str1) is 6 due to the EOL character. len(str2) is 5 as backslash (\) character is not counted in the length of string. As len(str1) is greater than len(str2) so the output is True.

Answered By

22 Likes


Related Questions