Re: how to match list members in py3.x
On 11/25/2018 08:30 AM, Muhammad Rizwan wrote: > IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART > ASS. On 11/25/2018 08:49 AM, Muhammad Rizwan wrote: > IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART > ASS. On 11/25/2018 10:55 AM, Muhammad Rizwan wrote: > Yes please ignore. Don't need any help from you either. This behavior is not acceptable. Any more posts like this and you will be suspended from Python List. -- ~Ethan~ Python List Moderator -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
On 25/11/2018 11.41, Richard Damon wrote: > On 11/25/18 12:28 PM, Muhammad Rizwan wrote: >> handle = open('file.txt') >> newlist = list() >> for line in handle: >> #line.rstrip() >> linewords = line.split() >> print(linewords) >> >> for word in linewords: >> newlist.append(word) >> if word not in linewords: >> continue >> >> >> >> print('new: ',newlist) > > The first thing I note in looking at this is that the second loop will > run AFTER the first loop completes, not for each step of the loop, > because you outdented the code. > > Also, you unconditionally add the word, and THEN check if it is in the list. And the first thing that I note is that he checks to see if it is in the list from which it came. -- Michael F. Stemper Economists have correctly predicted seven of the last three recessions. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
On 25/11/2018 16:49, Muhammad Rizwan wrote: IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART ASS. *plonk* -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
On Sunday, 25 November 2018 13:48:42 UTC-5, Alister wrote: > On Sun, 25 Nov 2018 08:49:03 -0800, Muhammad Rizwan wrote: > > > On Sunday, 25 November 2018 10:59:46 UTC-5, Alister wrote: > >> On Sun, 25 Nov 2018 07:43:42 -0800, Muhammad Rizwan wrote: > >> > >> > for each word in each line how can we check to see if a word is > >> > already present in a list and if it is not how to append that word to > >> > a new list > >> > >> the 1st step is to stay awake in class & listen to your instructor, > >> then try to apply the principle involved > >> > >> We don't do homework for you > >> > >> when you have produced a program of you own (not necessarily working) > >> if you post it here then we will be more than happy to provide > >> constructive criticism > >> > >> > >> > >> > >> -- > >> "Show business is just like high school, except you get paid." > >> - Martin Mull > > > > IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART > > ASS. > > with an attitude like that I will go one better & ignore ALL your posts > > > > -- > Good news. Ten weeks from Friday will be a pretty good day. Yes please ignore. Don't need any help from you either. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
On Sun, 25 Nov 2018 08:49:03 -0800, Muhammad Rizwan wrote: > On Sunday, 25 November 2018 10:59:46 UTC-5, Alister wrote: >> On Sun, 25 Nov 2018 07:43:42 -0800, Muhammad Rizwan wrote: >> >> > for each word in each line how can we check to see if a word is >> > already present in a list and if it is not how to append that word to >> > a new list >> >> the 1st step is to stay awake in class & listen to your instructor, >> then try to apply the principle involved >> >> We don't do homework for you >> >> when you have produced a program of you own (not necessarily working) >> if you post it here then we will be more than happy to provide >> constructive criticism >> >> >> >> >> -- >> "Show business is just like high school, except you get paid." >> - Martin Mull > > IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART > ASS. with an attitude like that I will go one better & ignore ALL your posts -- Good news. Ten weeks from Friday will be a pretty good day. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
On 11/25/18 12:28 PM, Muhammad Rizwan wrote: > Below is my approach which I am sure is wrong somewhere and it doesn't work > the way expected, the append doesn't do anything in my code nor does it > returns any traceback all i see is a empty list printed at the end, I am > using win10 x64 python 3.x atom-editor. Please take a look if you can tell me > what am I doing wrong here. I want to check each list word by word if the > word is not repeated in the same list it should be appended to a 'newlist'. > Thanks in advance > > handle = open('file.txt') > newlist = list() > for line in handle: > #line.rstrip() > linewords = line.split() > print(linewords) > > for word in linewords: > newlist.append(word) > if word not in linewords: > continue > > > > print('new: ',newlist) The first thing I note in looking at this is that the second loop will run AFTER the first loop completes, not for each step of the loop, because you outdented the code. Also, you unconditionally add the word, and THEN check if it is in the list. -- Richard Damon -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
On Sunday, 25 November 2018 12:14:37 UTC-5, Joel Goldstick wrote: > On Sun, Nov 25, 2018 at 11:51 AM Muhammad Rizwan > <> wrote: > > > > On Sunday, 25 November 2018 11:41:56 UTC-5, Joel Goldstick wrote: > > > On Sun, Nov 25, 2018 at 11:36 AM Muhammad Rizwan > > > <> wrote: > > > > > > > > IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART > > > > ASS. > > > > > > > > > > > > -- > > > > https://mail.python.org/mailman/listinfo/python-list > > > > > > That isn't a productive way to get assistance. It is true that > > > people here are often very knowledgeable to help with python problems, > > > but as a rule, doing someone's homework isn't something people like > > > to do. > > > > > > On to your problem. You should understand lists and sets, and for > > > loops. Try some code and come back with what you have. Then you will > > > get help to go further > > > > > > -- > > > Joel Goldstick > > > http://joelgoldstick.com/blog > > > http://cc-baseballstats.info/stats/birthdays > > > > I have been trying since morning but it doesn't work. > > The way to use this mailing list is to explain your problem, which you > have done. Then, show the code you have written with the results it > produces. Its good to include the operating system you are using > (windows, linux, osx), and if your code produces a traceback, copy and > paste it here. > > Its common to be frustrated learning to write and writing code, but if > you want help you have to show something for others to help you with > > -- > > https://mail.python.org/mailman/listinfo/python-list > > > > -- > Joel Goldstick > http://joelgoldstick.com/blog > http://cc-baseballstats.info/stats/birthdays Below is my approach which I am sure is wrong somewhere and it doesn't work the way expected, the append doesn't do anything in my code nor does it returns any traceback all i see is a empty list printed at the end, I am using win10 x64 python 3.x atom-editor. Please take a look if you can tell me what am I doing wrong here. I want to check each list word by word if the word is not repeated in the same list it should be appended to a 'newlist'. Thanks in advance handle = open('file.txt') newlist = list() for line in handle: #line.rstrip() linewords = line.split() print(linewords) for word in linewords: newlist.append(word) if word not in linewords: continue print('new: ',newlist) -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
On Sun, Nov 25, 2018 at 11:51 AM Muhammad Rizwan wrote: > > On Sunday, 25 November 2018 11:41:56 UTC-5, Joel Goldstick wrote: > > On Sun, Nov 25, 2018 at 11:36 AM Muhammad Rizwan > > <> wrote: > > > > > > IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART ASS. > > > > > > > > > -- > > > https://mail.python.org/mailman/listinfo/python-list > > > > That isn't a productive way to get assistance. It is true that > > people here are often very knowledgeable to help with python problems, > > but as a rule, doing someone's homework isn't something people like > > to do. > > > > On to your problem. You should understand lists and sets, and for > > loops. Try some code and come back with what you have. Then you will > > get help to go further > > > > -- > > Joel Goldstick > > http://joelgoldstick.com/blog > > http://cc-baseballstats.info/stats/birthdays > > I have been trying since morning but it doesn't work. The way to use this mailing list is to explain your problem, which you have done. Then, show the code you have written with the results it produces. Its good to include the operating system you are using (windows, linux, osx), and if your code produces a traceback, copy and paste it here. Its common to be frustrated learning to write and writing code, but if you want help you have to show something for others to help you with > -- > https://mail.python.org/mailman/listinfo/python-list -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
On 25/11/2018 17:30, Muhammad Rizwan wrote: > IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART ASS. > > Why would anyone want to help you? -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
On Sunday, 25 November 2018 11:41:56 UTC-5, Joel Goldstick wrote: > On Sun, Nov 25, 2018 at 11:36 AM Muhammad Rizwan > <> wrote: > > > > IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART ASS. > > > > > > -- > > https://mail.python.org/mailman/listinfo/python-list > > That isn't a productive way to get assistance. It is true that > people here are often very knowledgeable to help with python problems, > but as a rule, doing someone's homework isn't something people like > to do. > > On to your problem. You should understand lists and sets, and for > loops. Try some code and come back with what you have. Then you will > get help to go further > > -- > Joel Goldstick > http://joelgoldstick.com/blog > http://cc-baseballstats.info/stats/birthdays I have been trying since morning but it doesn't work. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
On Sunday, 25 November 2018 10:59:46 UTC-5, Alister wrote: > On Sun, 25 Nov 2018 07:43:42 -0800, Muhammad Rizwan wrote: > > > for each word in each line how can we check to see if a word is already > > present in a list and if it is not how to append that word to a new list > > the 1st step is to stay awake in class & listen to your instructor, then > try to apply the principle involved > > We don't do homework for you > > when you have produced a program of you own (not necessarily working) if > you post it here then we will be more than happy to provide constructive > criticism > > > > > -- > "Show business is just like high school, except you get paid." > - Martin Mull IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART ASS. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
Thank you -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
On Sun, Nov 25, 2018 at 11:36 AM Muhammad Rizwan wrote: > > IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART ASS. > > > -- > https://mail.python.org/mailman/listinfo/python-list That isn't a productive way to get assistance. It is true that people here are often very knowledgeable to help with python problems, but as a rule, doing someone's homework isn't something people like to do. On to your problem. You should understand lists and sets, and for loops. Try some code and come back with what you have. Then you will get help to go further -- Joel Goldstick http://joelgoldstick.com/blog http://cc-baseballstats.info/stats/birthdays -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
On Sun, 2018-11-25 at 07:43 -0800, Muhammad Rizwan wrote: > for each word in each line how can we check to see if a word is already > present in a list and if it is not how to append that word to a new list For your problem consider a set. https://en.wikipedia.org/wiki/Set_theory For the python syntax consider the py3 tutorial. https://docs.python.org/3/tutorial/index.html HTH -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
IF YOU CAN'T HELP BETTER IGNORE THE POST AND DON'T TRY TO BE A SMART ASS. -- https://mail.python.org/mailman/listinfo/python-list
Re: how to match list members in py3.x
On Sun, 25 Nov 2018 07:43:42 -0800, Muhammad Rizwan wrote: > for each word in each line how can we check to see if a word is already > present in a list and if it is not how to append that word to a new list the 1st step is to stay awake in class & listen to your instructor, then try to apply the principle involved We don't do homework for you when you have produced a program of you own (not necessarily working) if you post it here then we will be more than happy to provide constructive criticism -- "Show business is just like high school, except you get paid." - Martin Mull -- https://mail.python.org/mailman/listinfo/python-list