python show newline characters in string print code example Example: count a newline in string python length = x.count('\n')