Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #40518
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-03-05 03:12 -0800 |
| References | <d5f0feb6-533a-445b-a89a-8113c1668e9d@googlegroups.com> <7345f1f5-d958-4fef-ad50-81fb526b4f2f@googlegroups.com> <mailman.2848.1362415074.2939.python-list@python.org> |
| Subject | Re: Question on for loop |
| From | Bryan Devaney <bryan.devaney@gmail.com> |
| Message-ID | <mailman.2877.1362481970.2939.python-list@python.org> (permalink) |
On Monday, March 4, 2013 4:37:11 PM UTC, Ian wrote: > On Mon, Mar 4, 2013 at 7:34 AM, Bryan Devaney <bryan.devaney@gmail.com> wrote: > > >> if character not in lettersGuessed: > > >> > > >> return True > > >> > > >> return False > > > > > > assuming a function is being used to pass each letter of the letters guessed inside a loop itself that only continues checking if true is returned, then that could work. > > > > > > It is however more work than is needed. > > > > > > If you made secretword a list,you could just > > > > > > set(secretword)&set(lettersguessed) > > > > > > and check the result is equal to secretword. > > > > Check the result is equal to set(secretword), I think you mean. > > > > set(secretword).issubset(set(lettersguessed)) > > > > might be slightly more efficient, since it would not need to build and > > return an intersection set. > > > > One might also just do: > > > > all(letter in lettersguessed for letter in secretword) > > > > Which will be efficient if lettersguessed is already a set. You are correct. sorry for the misleading answer, was digging through old shell scripts all day yesterday and brain was obviously not not the better for it.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Question on for loop newtopython <roshen.sethna@gmail.com> - 2013-03-04 04:18 -0800
Re: Question on for loop leo kirotawa <kirotawa@gmail.com> - 2013-03-04 09:59 -0300
Re: Question on for loop Joel Goldstick <joel.goldstick@gmail.com> - 2013-03-04 08:04 -0500
Re: Question on for loop Dave Angel <davea@davea.name> - 2013-03-04 08:36 -0500
Re: Question on for loop Bryan Devaney <bryan.devaney@gmail.com> - 2013-03-04 06:34 -0800
Re: Question on for loop Ian Kelly <ian.g.kelly@gmail.com> - 2013-03-04 09:37 -0700
Re: Question on for loop Bryan Devaney <bryan.devaney@gmail.com> - 2013-03-05 03:12 -0800
Re: Question on for loop Bryan Devaney <bryan.devaney@gmail.com> - 2013-03-05 03:12 -0800
Re: Question on for loop Rick Johnson <rantingrickjohnson@gmail.com> - 2013-03-04 07:41 -0800
Re: Question on for loop Ricardo Aráoz <ricaraoz@gmail.com> - 2013-03-04 10:21 -0300
csiph-web