i know how to create a dictionary but how do i search for a pattern in a file and then create a dictionary based on the search
The problem is a little unclear. What should the contents of the dictionary look like?
contents of dictionary should have first name, last name, age and so on as the keys.
if i find john in the file populate that in the dict. as the value for first name. find his age and do the same. i hope this helps.
it would be better to show a sample input file, your expected output as well.
to search in a file. just an example...considering i don't know what your file structure is like.
for line in open("file"): if "john" in line: d['john'] = line