[Tutor] python challenges

jfouhy@paradise.net.nz jfouhy at paradise.net.nz
Fri May 6 02:30:31 CEST 2005


Quoting "D. Hartley" <denise.hartley at gmail.com>:

> I do have one question, however. I'm on riddle 3 ("re"), and got sent
> to the howto about regular expressions by the hint. But it did not
> seem (at least to me) very user-friendly: or perhaps I'm just not
> applying it to the problem correctly. I can see how I would use it if
> I were matching an exact bit of a string, for instance (like the
> "search" method), but if I'm checking for a series of cap/lowercase
> letters (but am not particular which character), I can't figure out
> how to use regular expressions to help me out.
 
[a-z] will match any single lower-case letter.  [A-Z] will match a single upper
case letter.  I guess this is the intended attack.

That said, when I solved riddle 3, I didn't even think to use regular
expressions.  I just used a list comprehsnsion :-)

(regex probably is a better way, though)

-- 
John.




More information about the Tutor mailing list