Hi All, Can anyone of your please help me to fix my code using re module? import os import re
txt=['199.72.81.55 - - [01/Jul/1995:00:00:01 -0400] "GET /history/apollo/ HTTP/1.0" 200 6245', 'unicomp6.unicomp.net - - [01/Jul/1995:00:00:06 -0400] "GET /shuttle/countdown/ HTTP/1.0" 200 3985', '199.120.110.21 - - [01/Jul/1995:00:00:09 -0400] "GET /shuttle/missions/sts-73/mission-sts-73.html HTTP/1.0" 200 4085'] l1= [] for i in range(0, len(txt)): s=txt[i] l1 += re.findall('"(.*?)"', s) print(l1) l2= [] for i in range(0, len(txt)): s=txt[i] l2 += re.findall(' (\d+ [^\s]+)', s) print(l2) I want l1 & l2 to be printed like below: Expected output: [('GET','/history/apollo/ HTTP/1.0'),('GET','/shuttle/countdown/ HTTP/1.0'),('GET','/shuttle/missions/sts-73/mission-sts-73.html HTTP/1.0')] ['6245','3985','4085'] But it is printing like below: Actual output: ['GET /history/apollo/ HTTP/1.0', 'GET /shuttle/countdown/ HTTP/1.0', 'GET /shuttle/missions/sts-73/mission-sts-73.html HTTP/1.0'] ['200 6245', '200 3985', '200 4085'] _______________________________________________ Chennaipy mailing list Chennaipy@python.org https://mail.python.org/mailman/listinfo/chennaipy