[Tutor] split or replace

Norman Khine norman at khine.net
Fri Jun 5 13:18:18 CEST 2009

What is the way to group each value so that I get a list, from a string like:

dir = '/expert/forum/expert/expert'
list = ['/expert', '/forum', '/expert', '/expert']

I've tried:
>>> dir = '/expert/forum'
>>> dir.split('/')
['', 'expert', 'forum']
>>> dir.replace("/expert","")
>>> dir = '/expert/forum/expert'
>>> dir.replace("/expert","")


More information about the Tutor mailing list