+ 1

len()

Why here answer is 5? not 3 or 7 S='A\nB\tC' print(len(S)) output:5

24th Jul 2018, 11:35 AM
tardigrade
tardigrade - avatar
4 Answers
+ 5
𝕾𝖆𝖌𝖆 he thought \n and \t didn't count
24th Jul 2018, 3:12 PM
LONGTIE👔
LONGTIE👔 - avatar
+ 2
S='A\nB\tC'#interpreter consider \n and \t as singler character so you are getting 5 print(len(S)) S=r'A\nB\tC'#note row string indicator r so for that you will get len as 7 because interprter \ and n as seperate character same for \t print(len(S)) How are you expecting 3 here?
24th Jul 2018, 12:08 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar
+ 1
Ohh, I understand already 𝕾𝖆𝖌𝖆 . Thank u very much
24th Jul 2018, 12:12 PM
tardigrade
tardigrade - avatar
+ 1
tardigrade No problem. Nice question.
24th Jul 2018, 12:13 PM
$¢𝐎₹𝔭!𝐨𝓝
$¢𝐎₹𝔭!𝐨𝓝 - avatar