I need help to understand this question. Please don't post the answer, only the ways to solve it.
Assign
10to the variablebase. Assign the set{0,1,2,3,4,5,6,7,8,9}to the variabledigits. Now write an expression using a comprehension andbaseanddigitswhose value is the set of all at-most- three-digit numbers. Your expression should work for any base. For example, if you instead assign2to base and assign{0,1}to digits, the value of your expression should be{0,1,2,3,4,5,6,7}because this is the set of numbers that, base two, have at most three digits.
I try this expression but I could not solve the base 2 question.
base = 10
digits = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
{(x*(base**2))+(y*(base**1))+(z*(base**0)) for x in digits for y in digits for z in digits if (x*(base**2))+(y*(base**1))+(z*(base**0))>((y*(base**1))+(z*(base**0)))}
range(int('%s%s%s'%(max_digit,max_digit_max_digit),base)+1)but that probably isnt what your teacher wantsifin the comprehension