Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. __author__ = 'Josh'
  2. def split_uppercase(string):
  3. string = string + " "
  4. loopCount = 0
  5. tokenlist = []
  6. typeList = []
  7. for i in string:
  8. if i.isupper():
  9. if string[loopCount + 1].islower():
  10. tokenlist.append(string[loopCount] + string[loopCount + 1])
  11. #tokenlist.append(string[loopCount + 1])
  12. typeList.append("element")
  13. #typeList.append("uppercase")
  14. #typeList.append("lowercase")
  15. else:
  16. tokenlist.append(string[loopCount])
  17. typeList.append("element")
  18. elif i.isnumeric():
  19. if string[loopCount + 1].isnumeric():
  20. tokenlist.append(string[loopCount] + string[loopCount + 1])
  21. typeList.append("numeric")
  22. #typeList.append("numeric")
  23. elif string[loopCount - 1].isnumeric():
  24. nop = 0 #Nop is NOP
  25. else:
  26. tokenlist.append(string[loopCount])
  27. typeList.append("numeric")
  28. loopCount += 1
  29. loopCount = 0
  30. for i in typeList:
  31. if typeList[loopCount] == "numeric":
  32. for j in range(int(tokenlist[loopCount])):
  33. tokenlist.append(tokenlist[loopCount-1])
  34. # tokenlist.remove(tokenlist[loopCount])
  35. #tokenlist[loopCount] = tokenlist[loopCount-1]
  36. loopCount += 1
  37. # loopCount = 0
  38. # for i in typeList:
  39. # if typeList[loopCount] == "numeric":
  40. # tokenlist.remove(tokenlist[loopCount])
  41. # loopCount += 1
  42. loopCount = 0
  43. for i in string:
  44. if i.isupper():
  45. if string[loopCount + 1].islower():
  46. tokenlist.remove(i + string[loopCount + 1])
  47. else:
  48. tokenlist.remove(i)
  49. loopCount += 1
  50. loopCount = 0
  51. for i in tokenlist:
  52. if i.isnumeric():
  53. tokenlist.remove(i)
  54. loopCount += 1
  55. return tokenlist, typeList
  56. exampleTokenList, exampleTypeList = split_uppercase("R5Br4K2O73")
  57. print(exampleTokenList)
  58. print(exampleTypeList)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement