Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # left - right replace
- #---------------------------------
- x = ['0l77r3','0lr5']
- def check(m): # function that operates left & right condition
- strRepl = m.replace('', ' ')
- toStr = str(strRepl)
- toList = toStr.split(' ')
- final = ''
- for i,o in enumerate(toList):
- if o == 'l':
- getInd = toList.index(o)
- toList[i] = o.replace(toList[getInd], toList[getInd - 1])
- if o == 'r':
- getInd = toList.index(o)
- toList[i] = o.replace(toList[getInd], toList[getInd + 1])
- for i in toList:
- final += i
- return final
- for m in x:
- print(check(m))
Advertisement
Add Comment
Please, Sign In to add comment