split a text file into multiple paragraphs python 1

split a text file into multiple paragraphs python

txt = "welcome to the jungle"

x = txt.split("\n")

print(x)

Here is what the above code is Doing:
1. We create a variable called txt, and assign it a string value.
2. We create a variable called x, and assign it the value of txt.split(“\n”).
3. The split() method splits the variable txt into substrings, and returns them as an array.
4. The “\n” is a special character that represents a new line.
5. The output of the code above will be:

[‘welcome to the jungle’]

Similar Posts