nums = [i for i in range(1,10000)]
b=[x for x in nums if '7' in x ]
print (b)
TypeError: argument of type 'int' is not iterable
nums = [i for i in range(1,10000)]
b=[x for x in nums if '7' in x ]
print (b)
TypeError: argument of type 'int' is not iterable
Create a Boolean generator for the given condition, and call sum on it, you will get the number of integers that evaluates to be True for the given condition.
>>>sum('7' in str(i) for i in range(1,10000))
3439
nums = [i for i in range(1,10000)]
b=[x for x in nums if '7' in str(x) ]
print (len(b))
print(b)
nums = [i for i in range(1,100)]
b=[x for x in str(nums) if '7' in x]
print(f'There are {len(b)} numbers that contain the number 7.')