So here is my situation
1. I am given a file with multiple paragraphs of random text.
2. A new paragraph is specified by a empty line or \n of course
3. I need to read through the file and separate each paragraph from each other, and I would like to make a dictionary
4. So I want the key in my dictionary to be the paragraph number
5. Then the value to be a list of each line in that paragraph.
example of output below (by the way '#'s' are comments so I can help explain what I want)
#File 1:
#paragraph 1
'hey my name is joe'
'I am from the US'
'I love to play sports'
\n
\n
#paragraph 2
'what do you like to do?'
'where are you from'
\n
\n
So that is the text file example
This is kind of what I want to do:
d = {}
d ={paragraph1 : [['hey my name is joe'], ['I am from the US'], ['I love to play sports']], paragraph2 : [['what do you like to do?'],['where are you from']]}
But since I wont know how many paragraphs are in the file, nor will I know how many lines are in the paragraph, how can I read the file create a standard key value such as paragraph and every time a new paragraph appears increment it by one....I imagine you will use a loop to do this.
1. I am given a file with multiple paragraphs of random text.
2. A new paragraph is specified by a empty line or \n of course
3. I need to read through the file and separate each paragraph from each other, and I would like to make a dictionary
4. So I want the key in my dictionary to be the paragraph number
5. Then the value to be a list of each line in that paragraph.
example of output below (by the way '#'s' are comments so I can help explain what I want)
#File 1:
#paragraph 1
'hey my name is joe'
'I am from the US'
'I love to play sports'
\n
\n
#paragraph 2
'what do you like to do?'
'where are you from'
\n
\n
So that is the text file example
This is kind of what I want to do:
d = {}
d ={paragraph1 : [['hey my name is joe'], ['I am from the US'], ['I love to play sports']], paragraph2 : [['what do you like to do?'],['where are you from']]}
But since I wont know how many paragraphs are in the file, nor will I know how many lines are in the paragraph, how can I read the file create a standard key value such as paragraph and every time a new paragraph appears increment it by one....I imagine you will use a loop to do this.


