Using A Function In A Loop Python