String Manipulation Function In Python