Re: [Tutor] Finding the differences between two lists

2011-08-25 Thread Justin Wendl
Robert, The lists were created using MS Notepad, and I forgot about the newlines - so you were absolutely right! So, is it possible to use strip() immediately when reading a file into a list to avoid confusion down the road, and is this common? Thank you everyone who contributed to this thread :

Re: [Tutor] Finding the differences between two lists

2011-08-25 Thread Robert Sjoblom
> shantanoo, Andre, and Robert: > > All of your solutions seem to work (and thank you for the tips!), however, > with each solution there seems to be 2 MACs that should not be in the > results. > > 00:1C:14:BA:D9:E9 and > 00:16:3E:EB:04:D9 > > should not be be turning up in the results because they

Re: [Tutor] Finding the differences between two lists

2011-08-25 Thread Justin Wendl
shantanoo, Andre, and Robert: All of your solutions seem to work (and thank you for the tips!), however, with each solution there seems to be 2 MACs that should not be in the results. 00:1C:14:BA:D9:E9 and 00:16:3E:EB:04:D9 should not be be turning up in the results because they are in the 'veri

Re: [Tutor] Finding the differences between two lists

2011-08-25 Thread Robert Sjoblom
> Scenario: I have a list of MAC addresses that are known and good, and am > comparing it to a list of MACs found in a scan.  I want to weed out the > those which are unknown.  I am using IDLE (Python 2.7) on Windows, and all > files are in the same directory. > > Code: > > scanResults = open('scan

Re: [Tutor] Finding the differences between two lists

2011-08-25 Thread Andre Engels
On Thu, Aug 25, 2011 at 9:08 PM, Justin Wendl wrote: > Hi John, > > Thanks for the quick response. Unfortunately it is returning the same > result.. > > This is caused by the else: break part of the the code. Break breaks out of the loop, thus you skip all following elements if you go throu

Re: [Tutor] Finding the differences between two lists

2011-08-25 Thread Justin Wendl
Giovanni, scanResults.txt: 00:16:3E:D0:26:25 00:16:3E:43:7D:24 00:16:3E:2D:6D:F8 00:16:3E:EB:04:D9 00:16:3E:FD:85:0B 00:1C:14:AF:04:39 00:1C:14:E3:D6:CA 00:1C:14:15:B2:C8 00:1C:14:47:5A:A0 00:1C:14:BA:D9:E9 verifiedList: 00:1C:14:BA:D9:E9 00:16:3E:D0:26:25 00:1C:14:AF:04:39 00:16:3E:EB:04:D9 - J

Re: [Tutor] Finding the differences between two lists

2011-08-25 Thread Giovanni Tirloni
On Thu, Aug 25, 2011 at 4:08 PM, Justin Wendl wrote: > Hi John, > > Thanks for the quick response.  Unfortunately it is returning the same > result.. Please send a small example of the contents in each file. -- Giovanni Tirloni sysdroid.com ___ Tutor

Re: [Tutor] Finding the differences between two lists

2011-08-25 Thread शंतनू
You may try using set instead of list. >>> verifiedList = {[1,2,3} >>> scanResults = {1,2,3,4,5} >>> badMacs = scanResults - verifiedList >>> badMacs set([4, 5]) >>> verifiedList = {1,2,3,7,8,9} >>> badMacs = scanResults - verifiedList >>> badMacs set([4, 5]) -- shantanoo On 26-Aug-2011, at 12:2

Re: [Tutor] Finding the differences between two lists

2011-08-25 Thread Justin Wendl
Hi John, Thanks for the quick response. Unfortunately it is returning the same result.. - Justin On Thu, Aug 25, 2011 at 2:59 PM, John wrote: > Not entirely sure, but I think it is as simple as: > > scanResults = open('scanResults.txt', 'r').readlines() > verifiedList = open('verifiedList.tx

Re: [Tutor] Finding the differences between two lists

2011-08-25 Thread John
Not entirely sure, but I think it is as simple as: scanResults = open('scanResults.txt', 'r').readlines() verifiedList = open('verifiedList.txt', 'r').readlines() Now both are lists. I assume each mac address is on it's own line? -john On Thu, Aug 25, 2011 at 8:56 PM, Justin Wendl wrote: > He