print same ID for all the elements in text1 and then icrementing the ID and priting for text2. -Python -
i have 2 text files text1.txt , text2.txt.
text1.txt contains:
sam mat tom
text2.txt contains:
robbie peter steve
i want output like:-
sam1 mat1 tom1 robbie2 peter2 steve2
so text1.txt elements, want print same id elements , increment id 1 , print corresponding elements/names in text2.txt shown above.
any help? thanks
try out:
files = ['text1.txt', 'text2.txt'] (id, file) in enumerate(files, start=1): open(file, 'r') f: line in f.xreadlines(): print line.strip() + str(id)
Comments
Post a Comment