String Function Program In Python Using Loop