While Loop Python String Functions Substring Method In Apex