Arrangements and Combinations · Basic Rules
Lesson 9
Complement rule: to calculate the number of objects with a certain property, you can subtract the number of objects without that property from the total number of objects. Or: if \(A \subseteq U\), then \(|A|=|U| - |U \setminus A|\).
Positive numbers with no more than four digits and where none of the digits equals seven will be \(9^{4}\): each of the four positions can have any of the nine digits (all except seven). Thus, the answer is \(10000-9^{4}=3439\).
print(len([n for n in range(10000) if '7' in str(n)]))3439