String Manipulation Python Problems On Loops