I have a long text in python. It consists of 20 rows. Is there any way I can get the text up until a certain row?
Let's say that the text is called text_variable.
I would the like to be able to do something like
first_seven_rows = text_variable[:row 7]
print(first_seven_rows)
should then return the first seven lines of the text.
Could this maybe be done with regex? How do I specify that I want regex to extract everything up until the seventh "\n"?
I hope you understand my question.