From: "Shot (Piotr Szotkowski)" Date: 2009-11-24T01:52:29+09:00 Subject: Re: Best way to search through an array for an item matching a s --fUYQa+Pmc3FrFX/N Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Daniel Webb: > am trying to find a nice easy/simple way to > - search through an array of strings match the string I've input > - use that index to print out the word before in the array. > for example > [ahoy there,hello,me hearties,dear friends] > 'hello' should output 'ahoy there' dict =3D ['ahoy there', 'hello', 'me hearties', 'dear friends'] dict[dict.index('hello') - 1] # =3D> 'ahoy there' =E2=80=94 Shot --=20 The duck sauce contains =E2=80=98vegetable stabilizer=E2=80=99 which sounds ominous. I mean, how unstable are vegetables? [jzahn, asr] --fUYQa+Pmc3FrFX/N Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAksKvYUACgkQi/mCfdEo8UriNQCeM0+G6ge+gLJAj5lULhntwliX 4b0An2mqoMYB3Xki8ImSu29WTSbwxb9q =Xi/F -----END PGP SIGNATURE----- --fUYQa+Pmc3FrFX/N--