Answer the question
In order to leave comments, you need to log in
Is there a library or built-in method in Python that counts the number of lines(\n) in a string(" ")?
It is necessary to iterate not over the individual elements of the line, but over its lines, no matter how strange it may sound. Is there any method that would count the strings in the string "".
Answer the question
In order to leave comments, you need to log in
toshk9 , this is also possible:
>>> a = """ добрый день
... сейчас я на работе
... освобожусь позже
... и перезвоню
... """
>>> c = a.count("\n")
>>> c
4
>>>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question