#def split_string(source,splitlist): # source=[int(s) for s in a_temp] # finlist=[] # i=0 # x=0 #if source[0] not in splitlist: # finlist.append([source[0]]) # i+=1 #while i < len(source): # # if source[i] not in splitlist: # if source[i-1] in splitlist: # finlist.append([source[i]]) # x+=1 # else: # finlist[x].append(source[i]) #i+=1 #return finlist def split_string(source,splitlist): source=[int(s) for s in a_temp] finlist=[] i=0 x=0 if source[0] not in splitlist: finlist.append([source[0]]) i+=1 while i<len(source): while source[i+1] not in splitlist: if type(finlist[x]) is str: finlist[x]=[finlist[x]] finlist[x].append(source[i]) if len(finlist[x])==1: str(finslist[x]) else: ''.join(finlist[x]) i+=1 print finlist
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question