Python Iterate Over Array With Function