Java String Manipulation Functions Python Code