[Tutor] how to print lines which contain matching words or strings

Bob Gailer bgailer at gmail.com
Sun Nov 18 13:41:29 EST 2018


On Nov 18, 2018 1:19 PM, "Bob Gailer" <bgailer at gmail.com> wrote:
>
> On Nov 18, 2018 12:14 PM, "Asad" <asad.hasan2004 at gmail.com> wrote:
> >
> > Hi All ,
> >
> >        I have a set of words and strings :
> >
> > like :
> >
> > p = [A ,"B is good" ,123456 , "C "]
> >
> > I have a file in which I need to print only the lines which matches the
> > pattern in p
> >
> > thanks,

Terminology is very important. You say set then you show us a list.

You say words and strings, but your list contains a python identifier and a
number in addition to Strings.

You say pattern but don't Define what you mean by pattern. I could not
begin to guess what your definition of pattern is.

We also do not know what the term word means to you. You may say that is
obvious but it is not. So tell us your meaning of word.

To make the question meaningful I would suggest you show us sample of the
file indicating lines that meet the pattern and lines that don't.

Please realize that we are not here to write code for you, rather we like
to help you when we see you put in some effort. So I suggest you write a
Python program that attempts to do what you want, then tell us where the
program isn't doing what you want or where you are stuck will try to help.

Please respond in some way so that we know you have heard us.


More information about the Tutor mailing list