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
axn 0 Light Poster
Recommended Answers
Jump to Postit 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
All 4 Replies
jrcagle 77 Practically a Master Poster
axn 0 Light Poster
woooee 814 Nearly a Posting Maven
ghostdog74 57 Junior Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.