66 935
Assignments Done
99,1%
Successfully Done
In October 2018

Answer to Question #3387 in Python for mukunda

Question #3387
Write about yourself in a text file and save it as “aboutme.txt” take a search string as “name” and find that string in the “aboume.txt” file.
Expert's answer
import re

source = "Me is Rahmadja Abdulaevich.\nMe learn python."
search = "Rahmadja"

fout = open ("aboutme.txt", "w")
fout.write (source)
fout.close()

for s in open ("aboutme.txt"):
if re.search( search, s ):
& print( search, "is at", re.search( search, source ).start(0), "position of the line:", s )
& break

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions