要求
1、输入一个数字N,判断1-N之间,要跳过所有含有7或者能被7整除的数字,把这些数字打印出来
# 可以随意传入一个数字,做1-endNum之间所有数字的判断
def skin_seven(endNum):
a = []
for i in range(endNum+1):
if i % 7 != 0 :
res = re.findall(r"7",str(i))
if res == []:
a.append(i)
# print(a)
return a
if __name__ == '__main__':
x = skin_seven(110)
print(x)
得到结果
[1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 15, 16, 18, 19, 20, 22, 23, 24, 25, 26, 29, 30, 31, 32, 33, 34, 36, 38, 39, 40, 41, 43, 44, 45, 46, 48, 50, 51, 52, 53, 54, 55, 58, 59, 60, 61, 62, 64, 65, 66, 68, 69, 80, 81, 82, 83, 85, 86, 88, 89, 90, 92, 93, 94, 95, 96, 99, 100, 101, 102, 103, 104, 106, 108, 109, 110]
标签:__,数字,endNum,python,110,skin,跳过,游戏 From: https://www.cnblogs.com/felixlhp/p/16827447.html