This problem is in Contest(s) below:
Contest 1047:2021-WE 百题大战07:函数+循环威力大
Contest 1040:SISO第1届Python程序设计竞赛