Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #97980
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2015-10-28 07:05 -0700 |
| References | <25e0abea-f1a6-446c-af4e-f01fb5b482f0@googlegroups.com> |
| Message-ID | <1a678d2e-9bf7-4199-9989-1d88942996b4@googlegroups.com> (permalink) |
| Subject | Re: i want to print next element i liste |
| From | darnold <darnold992000@yahoo.com> |
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
Back to comp.lang.python | Previous | Next — Previous in thread | Next 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