Python Count Lines in String
txt = 'line1\nline2\nline3\n' # Three newline characters
print(txt.count('\n')) # prints: 3
Yaakov Belch
txt = 'line1\nline2\nline3\n' # Three newline characters
print(txt.count('\n')) # prints: 3