Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97979 > unrolled thread
| Started by | ellelelet@gmail.com |
|---|---|
| First post | 2015-10-28 05:23 -0700 |
| Last post | 2015-10-29 12:48 +0000 |
| Articles | 10 — 6 participants |
Back to article view | Back to comp.lang.python
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
| From | ellelelet@gmail.com |
|---|---|
| Date | 2015-10-28 05:23 -0700 |
| Subject | i want to print next element i liste |
| Message-ID | <25e0abea-f1a6-446c-af4e-f01fb5b482f0@googlegroups.com> |
L=[house, book, pen, book, pencil, book, clock, cat, book, good, write]
for i,w in enumerate(L):
if L.count(w)>=3:
order_list.append(i)
print i,w
result:
1 book
3 book
5 book
8 book
how can i print "good" then? it comes after last book element.
[toc] | [next] | [standalone]
| From | darnold <darnold992000@yahoo.com> |
|---|---|
| Date | 2015-10-28 07:05 -0700 |
| Message-ID | <1a678d2e-9bf7-4199-9989-1d88942996b4@googlegroups.com> |
| In reply to | #97979 |
On Wednesday, October 28, 2015 at 7:23:40 AM UTC-5, Ellelele Toget wrote: > L=[house, book, pen, book, pencil, book, clock, cat, book, good, write] > for i,w in enumerate(L): > if L.count(w)>=3: > order_list.append(i) > print i,w > > result: > 1 book > 3 book > 5 book > 8 book > how can i print "good" then? it comes after last book element. presumably, L is actually a list of strings. that aside, your condition on printing a word is that it appears in L three or more times: > if L.count(w)>=3: > order_list.append(i) > print i,w 'book' appears in the list less than three times, so it doesn't satisfy the condition and isn't printed. HTH, Don
[toc] | [prev] | [next] | [standalone]
| From | darnold <darnold992000@yahoo.com> |
|---|---|
| Date | 2015-10-28 07:16 -0700 |
| Message-ID | <412f85b2-9b0c-462b-a2db-8c55d3136b46@googlegroups.com> |
| In reply to | #97980 |
On Wednesday, October 28, 2015 at 9:05:59 AM UTC-5, darnold wrote: > On Wednesday, October 28, 2015 at 7:23:40 AM UTC-5, Ellelele Toget wrote: > > L=[house, book, pen, book, pencil, book, clock, cat, book, good, write] > > for i,w in enumerate(L): > > if L.count(w)>=3: > > order_list.append(i) > > print i,w > > > > result: > > 1 book > > 3 book > > 5 book > > 8 book > > how can i print "good" then? it comes after last book element. > > presumably, L is actually a list of strings. > > that aside, your condition on printing a word is that it appears in L three or more times: > > > if L.count(w)>=3: > > order_list.append(i) > > print i,w > > 'book' appears in the list less than three times, so it doesn't satisfy the condition and isn't printed. > > HTH, > Don whoops. that should read: 'good' appears in the list less than three times, so it doesn't satisfy the condition and isn't printed. sorry for any confusion, Don
[toc] | [prev] | [next] | [standalone]
| From | Ellelele Toget <ellelelet@gmail.com> |
|---|---|
| Date | 2015-10-28 07:34 -0700 |
| Message-ID | <76077a86-40cf-42b0-bace-a8c25c03729e@googlegroups.com> |
| In reply to | #97979 |
On Wednesday, October 28, 2015 at 1:23:40 PM UTC+1, Ellelele Toget wrote: > L=[house, book, pen, book, pencil, book, clock, cat, book, good, write] > for i,w in enumerate(L): > if L.count(w)>=3: > order_list.append(i) > print i,w > > result: > 1 book > 3 book > 5 book > 8 book > how can i print "good" then? it comes after last book element. next() function print next element in dictionary but this is a list therefore is there Another function for list like next() or Another codes
[toc] | [prev] | [next] | [standalone]
| From | Christian Gollwitzer <auriocus@gmx.de> |
|---|---|
| Date | 2015-10-28 17:12 +0100 |
| Message-ID | <n0qs11$3v5$1@dont-email.me> |
| In reply to | #97982 |
Am 28.10.15 um 15:34 schrieb Ellelele Toget: > On Wednesday, October 28, 2015 at 1:23:40 PM UTC+1, Ellelele Toget wrote: >> L=[house, book, pen, book, pencil, book, clock, cat, book, good, write] >> for i,w in enumerate(L): >> if L.count(w)>=3: >> order_list.append(i) >> print i,w >> >> result: >> 1 book >> 3 book >> 5 book >> 8 book >> how can i print "good" then? it comes after last book element. > next() function print next element in dictionary but this is a list therefore is there Another function for list like next() or Another codes > L[i+1] ??? Christian
[toc] | [prev] | [next] | [standalone]
| From | Ellelele Toget <ellelelet@gmail.com> |
|---|---|
| Date | 2015-10-28 14:58 -0700 |
| Message-ID | <f4b6cec8-0404-46ee-bc60-49f721c5cb6e@googlegroups.com> |
| In reply to | #97983 |
On Wednesday, October 28, 2015 at 5:12:45 PM UTC+1, Christian Gollwitzer wrote:
> Am 28.10.15 um 15:34 schrieb Ellelele Toget:
> > On Wednesday, October 28, 2015 at 1:23:40 PM UTC+1, Ellelele Toget wrote:
> >> L=[house, book, pen, book, pencil, book, clock, cat, book, good, write]
> >> for i,w in enumerate(L):
> >> if L.count(w)>=3:
> >> order_list.append(i)
> >> print i,w
> >>
> >> result:
> >> 1 book
> >> 3 book
> >> 5 book
> >> 8 book
> >> how can i print "good" then? it comes after last book element.
> > next() function print next element in dictionary but this is a list therefore is there Another function for list like next() or Another codes
> >
>
> L[i+1]
>
> ???
>
> Christian
L=[house, book, pen, book, pencil, book, clock, cat, book, good, write]
for i, w enumerate(L):
if L.count(w)>=3:
print L[i+1]
result:
pen
pencil
Clock
good
[toc] | [prev] | [next] | [standalone]
| From | Ellelele Toget <ellelelet@gmail.com> |
|---|---|
| Date | 2015-10-28 15:02 -0700 |
| Message-ID | <0cb60a10-186b-45fb-8170-28003e901921@googlegroups.com> |
| In reply to | #97987 |
On Wednesday, October 28, 2015 at 10:59:19 PM UTC+1, Ellelele Toget wrote: > On Wednesday, October 28, 2015 at 5:12:45 PM UTC+1, Christian Gollwitzer wrote: > > Am 28.10.15 um 15:34 schrieb Ellelele Toget: > > > On Wednesday, October 28, 2015 at 1:23:40 PM UTC+1, Ellelele Toget wrote: > > >> L=[house, book, pen, book, pencil, book, clock, cat, book, good, write] > > >> for i,w in enumerate(L): > > >> if L.count(w)>=3: > > >> order_list.append(i) > > >> print i,w > > >> > > >> result: > > >> 1 book > > >> 3 book > > >> 5 book > > >> 8 book > > >> how can i print "good" then? it comes after last book element. > > > next() function print next element in dictionary but this is a list therefore is there Another function for list like next() or Another codes > > > > > > > L[i+1] > > > > ??? > > > > Christian > > L=[house, book, pen, book, pencil, book, clock, cat, book, good, write] > for i, w enumerate(L): > if L.count(w)>=3: > print L[i+1] > result: > pen > pencil > Clock > good i will only good
[toc] | [prev] | [next] | [standalone]
| From | Larry Hudson <orgnut@yahoo.com> |
|---|---|
| Date | 2015-10-28 19:12 -0700 |
| Message-ID | <sPudnc0nj4EbHazLnZ2dnUU7-a2dnZ2d@giganews.com> |
| In reply to | #97988 |
On 10/28/2015 03:02 PM, Ellelele Toget wrote:
> On Wednesday, October 28, 2015 at 10:59:19 PM UTC+1, Ellelele Toget wrote:
>> On Wednesday, October 28, 2015 at 5:12:45 PM UTC+1, Christian Gollwitzer wrote:
>>> Am 28.10.15 um 15:34 schrieb Ellelele Toget:
>>>> On Wednesday, October 28, 2015 at 1:23:40 PM UTC+1, Ellelele Toget wrote:
>>>>> L=[house, book, pen, book, pencil, book, clock, cat, book, good, write]
>>>>> for i,w in enumerate(L):
>>>>> if L.count(w)>=3:
>>>>> order_list.append(i)
>>>>> print i,w
>>>>>
>>>>> result:
>>>>> 1 book
>>>>> 3 book
>>>>> 5 book
>>>>> 8 book
>>>>> how can i print "good" then? it comes after last book element.
[snip]
>
> i will only good
>
You will have to explain to us what is special about 'good' that makes it different from
'house', 'pen', 'pencil', 'clock', 'cat' or 'write'.
-=- Larry -=-
[toc] | [prev] | [next] | [standalone]
| From | Ellelele Toget <ellelelet@gmail.com> |
|---|---|
| Date | 2015-10-29 01:55 -0700 |
| Message-ID | <fea1d5fa-e3c8-40f4-9372-669634938718@googlegroups.com> |
| In reply to | #97989 |
On Thursday, October 29, 2015 at 3:12:49 AM UTC+1, Larry Hudson wrote: > On 10/28/2015 03:02 PM, Ellelele Toget wrote: > > On Wednesday, October 28, 2015 at 10:59:19 PM UTC+1, Ellelele Toget wrote: > >> On Wednesday, October 28, 2015 at 5:12:45 PM UTC+1, Christian Gollwitzer wrote: > >>> Am 28.10.15 um 15:34 schrieb Ellelele Toget: > >>>> On Wednesday, October 28, 2015 at 1:23:40 PM UTC+1, Ellelele Toget wrote: > >>>>> L=[house, book, pen, book, pencil, book, clock, cat, book, good, write] > >>>>> for i,w in enumerate(L): > >>>>> if L.count(w)>=3: > >>>>> order_list.append(i) > >>>>> print i,w > >>>>> > >>>>> result: > >>>>> 1 book > >>>>> 3 book > >>>>> 5 book > >>>>> 8 book > >>>>> how can i print "good" then? it comes after last book element. > > [snip] > > > > > i will only good > > > You will have to explain to us what is special about 'good' that makes it different from > 'house', 'pen', 'pencil', 'clock', 'cat' or 'write'. > > -=- Larry -=- When the transmitting host receives least three duplicate ACKs from the recipient it assumes the packet was indeed lost in transit and immediately sends a fast retransmission. This fast retransmission is different than a standard retransmission because once it is triggered all other packets being transmitted are queued until it is sent. 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:)
[toc] | [prev] | [next] | [standalone]
| From | Denis McMahon <denismfmcmahon@gmail.com> |
|---|---|
| Date | 2015-10-29 12:48 +0000 |
| Message-ID | <n0t4j2$b2m$1@dont-email.me> |
| In reply to | #97993 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web