Hi! Not directly. You will need to rewrite the code from Typescript to Python. The good news is that it's just 35 lines of code.
Here's the source: github.com/tawn33y/ussd-router/blo...
Let me know if you face any issues. Cheers!
Hi ! Thanks a lot. I have encoded the lines below and it's work perfectly :
def goBack(str, keyword='00'):
strArray = str.split('*') newStrArray = []
for i in range(len(strArray)):
if strArray[i] == keyword: newStrArray = newStrArray[slice(0, -1)] else: newStrArray.append(strArray[i])
return "*".join(newStrArray)
def goToHome(str, keyword='0'):
strArray = str.split('*') newStr = str
for i in reversed(range(len(strArray))): if strArray[i] == keyword: newStr = "*".join(strArray[i+1:]) break
return newStr
def ussdRouter(str, goToHomeKeyword='0', goBackKeyword='00'): return goBack(goToHome(str, goToHomeKeyword), goBackKeyword)
This is great!! 🙌🏽
Thanks for sharing! When you get a minute, feel free to create a python package for the same, and I can add a hyperlink pointer to this in the js package for future people who would like a python version
github.com/ditsarl/ussdrouter.git
Awesome! 🙌🏽
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Hi! Not directly. You will need to rewrite the code from Typescript to Python. The good news is that it's just 35 lines of code.
Here's the source: github.com/tawn33y/ussd-router/blo...
Let me know if you face any issues.
Cheers!
Hi ! Thanks a lot. I have encoded the lines below and it's work perfectly :
coding: utf-8
def goBack(str, keyword='00'):
strArray = str.split('*')
newStrArray = []
for i in range(len(strArray)):
return "*".join(newStrArray)
def goToHome(str, keyword='0'):
strArray = str.split('*')
newStr = str
for i in reversed(range(len(strArray))):
if strArray[i] == keyword:
newStr = "*".join(strArray[i+1:])
break
return newStr
def ussdRouter(str, goToHomeKeyword='0', goBackKeyword='00'):
return goBack(goToHome(str, goToHomeKeyword), goBackKeyword)
This is great!! 🙌🏽
Thanks for sharing! When you get a minute, feel free to create a python package for the same, and I can add a hyperlink pointer to this in the js package for future people who would like a python version
github.com/ditsarl/ussdrouter.git
Awesome! 🙌🏽