Substring Index Python Function Return