I am supposed to print a random 5-digit number with no repeating digits, then ask the user for a three digit number. If the user\'s number contains three digits from the ran
If you generate your numbers like this:
larger_number = ''.join(random.sample(string.digits, 5))
And got the numbers from the user like this:
def get_user_num(length=5):
while True:
num = raw_input('Enter a {}-digit number with no repeating digits: '.format(length)).zfill(length)
if len(set(num)) < length:
print('Please try again.')
continue
else:
return num
You could determine if the user's numbers were in the number list like so:
set(user_number) < set(larger_number)
And then it would be a really simple matter to combine this all together into a program. Note that the numbers are never actually treated as numbers - they're just strings.