Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Very simple python question

Name: Anonymous 2010-10-07 21:18

>>> prefixes("overall")
['', 'o', 'ov', 'ove', 'over', 'overa', 'overal', 'overall']

I need to be able to return the statement above, so far all I have is:

def prefixes(x):
    return [v for v in

I don't know where to go from here or if what I have so far is wrong, but I know that the statement should only be about 1-2 lines.  I was told that there should be a slicing statement

is anyone able to help me with this program?

Name: Anonymous 2010-10-08 1:15


def prefixes(alist):
   s = [i for i in alist]
   for i in range(s.__len__()):
      print s[0:i+1]


your job is to make the list of strings according to your original output

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List