Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97998
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: i want to print next element i liste |
| Date | 2015-10-29 12:48 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <n0t4j2$b2m$1@dont-email.me> (permalink) |
| References | (2 earlier) <n0qs11$3v5$1@dont-email.me> <f4b6cec8-0404-46ee-bc60-49f721c5cb6e@googlegroups.com> <0cb60a10-186b-45fb-8170-28003e901921@googlegroups.com> <sPudnc0nj4EbHazLnZ2dnUU7-a2dnZ2d@giganews.com> <fea1d5fa-e3c8-40f4-9372-669634938718@googlegroups.com> |
On Thu, 29 Oct 2015 01:55:51 -0700, Ellelele Toget wrote:
> i put all packets in list and after i will find least 3 duplicate
> packets and it print soon coming next packet, if it is 3 duplicate
> packets it print 4. packet. if it is 25 duplicate packet it print 26.
> packet. Algorithm run so:)
So in a list of things, you want to find the thing that comes after the
third occurrence of another thing.
Now I think we know what you actually want to do.
This probably isn't the best way to do it, but it seems to work:
#!/usr/bin/python
l = ["house", "book", "pen", "book", "pencil", "book", "clock", "cat",
"book", "good", "write"]
d = {}
flag = False
for thing in l:
if flag:
print thing
break
else:
if thing in d:
d[thing] = d[thing] + 1
if d[thing] == 3:
flag = True
else:
d[thing] = 1
--
Denis McMahon, denismfmcmahon@gmail.com
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
i want to print next element i liste ellelelet@gmail.com - 2015-10-28 05:23 -0700
Re: i want to print next element i liste darnold <darnold992000@yahoo.com> - 2015-10-28 07:05 -0700
Re: i want to print next element i liste darnold <darnold992000@yahoo.com> - 2015-10-28 07:16 -0700
Re: i want to print next element i liste Ellelele Toget <ellelelet@gmail.com> - 2015-10-28 07:34 -0700
Re: i want to print next element i liste Christian Gollwitzer <auriocus@gmx.de> - 2015-10-28 17:12 +0100
Re: i want to print next element i liste Ellelele Toget <ellelelet@gmail.com> - 2015-10-28 14:58 -0700
Re: i want to print next element i liste Ellelele Toget <ellelelet@gmail.com> - 2015-10-28 15:02 -0700
Re: i want to print next element i liste Larry Hudson <orgnut@yahoo.com> - 2015-10-28 19:12 -0700
Re: i want to print next element i liste Ellelele Toget <ellelelet@gmail.com> - 2015-10-29 01:55 -0700
Re: i want to print next element i liste Denis McMahon <denismfmcmahon@gmail.com> - 2015-10-29 12:48 +0000
csiph-web