Very new to this, appreciate your patience.
I have a txt file of a poem. Ultimately I want create a dictionary such that my key is the line# and the value is the text on that line. For instance, if my poem is this:
Roses are red,
Violets are blue.
I would like my dictionary to be:
dictionary = {1: 'Roses are red', 2: 'Violets are blue'}
Ultimately I want my program to allow me to search for a line of the poem by entering the line number (the key).
I've started off by doing this--
def getFile():
prose = str(input('Please enter the file path for your text file: '))
dictionary = {}
infile = open(prose, 'r')
for line in infile:
dictionary[line] += 1
print(dictionary)
infile.close()
getFile()
But I'm lost and don't know what to do next. I've tried looking this up, I'm not understanding this. Any help would be much appreciated.