Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'Josh'
- def split_uppercase(string):
- string = string + " "
- loopCount = 0
- tokenlist = []
- typeList = []
- for i in string:
- if i.isupper():
- if string[loopCount + 1].islower():
- tokenlist.append(string[loopCount] + string[loopCount + 1])
- #tokenlist.append(string[loopCount + 1])
- typeList.append("element")
- #typeList.append("uppercase")
- #typeList.append("lowercase")
- else:
- tokenlist.append(string[loopCount])
- typeList.append("element")
- elif i.isnumeric():
- if string[loopCount + 1].isnumeric():
- tokenlist.append(string[loopCount] + string[loopCount + 1])
- typeList.append("numeric")
- #typeList.append("numeric")
- elif string[loopCount - 1].isnumeric():
- nop = 0 #Nop is NOP
- else:
- tokenlist.append(string[loopCount])
- typeList.append("numeric")
- loopCount += 1
- loopCount = 0
- for i in typeList:
- if typeList[loopCount] == "numeric":
- for j in range(int(tokenlist[loopCount])):
- tokenlist.append(tokenlist[loopCount-1])
- # tokenlist.remove(tokenlist[loopCount])
- #tokenlist[loopCount] = tokenlist[loopCount-1]
- loopCount += 1
- # loopCount = 0
- # for i in typeList:
- # if typeList[loopCount] == "numeric":
- # tokenlist.remove(tokenlist[loopCount])
- # loopCount += 1
- loopCount = 0
- for i in string:
- if i.isupper():
- if string[loopCount + 1].islower():
- tokenlist.remove(i + string[loopCount + 1])
- else:
- tokenlist.remove(i)
- loopCount += 1
- loopCount = 0
- for i in tokenlist:
- if i.isnumeric():
- tokenlist.remove(i)
- loopCount += 1
- return tokenlist, typeList
- exampleTokenList, exampleTypeList = split_uppercase("R5Br4K2O73")
- print(exampleTokenList)
- print(exampleTypeList)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement