homework py corrected according to x-treme comments