题解 | #挑7#
挑7
https://www.nowcoder.com/practice/ba241b85371c409ea01ac0aa1a8d957b?tpId=37&tqId=21278&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D2%26tpId%3D37%26type%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=
import sys ''' 先将s转化为字符串,然后遍历字符串 ''' s =int(input()) def select7(s): ''' 当7在i中,或者i能被7整除,将i添加到L中 ''' i=1 L=[] while i <= s: if "7" in str(i) or i%7==0 : L.append(i) else: pass i+=1 print(len(L)) return 0 #调用select7函数 select7(s)