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
Use zfill and set like so: Edited to account for numbers with repeating digits
import random
def threeInFive(user_num):
num = str(random.randint(0, 99999)).zfill(5)
num = ''.join(set([n for n in num]))
if len(num) < 5:
print "There were repeating digits...trying again"
threeInFive(user_num)
elif str(user_num) in num:
print "The user number is in there!"
return True
else:
print "The user number : %s is not in : %s" % (user_num, num)
return False
threeInFive(500)