problem39 python