Python Programming Challenges for beginners?
Paul Rudin
paul.nospam at rudin.co.uk
Fri Nov 27 11:00:32 EST 2009
n00m <n00m at narod.ru> writes:
> On Nov 27, 1:22 pm, Jon Clements <jon... at googlemail.com> wrote:
>> Of course, if you take '~' literally (len(s) <= -10001) I reckon
>> you've got way too many :)
>>
>> Jon.
>
> Then better: len(s) < abs(~10000)
>
> PS It's a hard problem; so let's leave it alone
what's hard? substrings of a string? If you don't care too much about
efficiency it's easy enough:
import itertools
def subs(s):
return set(itertools.chain(
s[i:j]
for i in xrange(len(s))
for j in xrange(i, len(s)+1)))
More information about the Python-list
mailing list