I am trying to compare two lists on line #12
and return matches found.
The lists contain one user selected number (un
) and one of which have been randomly generated (rn
).
For example, [['1', '5', '3', '7']]
and [['9', '6', '3', '2']]
would return [3]
.
I am fairly new to python and was using the solution found HERE, but am yet to have success with my code.
import random
import re
rn = []
un = []
Numbers = range(1000,9999)
RandomNumber = random.choice(Numbers)
RandomNumber = str(RandomNumber)
def check():
x = set(rn) & set(un) #12
print (x)
def numsys():
b = list(RandomNumber)
rn.append(b)
print(rn)
print(un)
check()
def numval():
while True:
UserNum = (input("Please enter a 4 digit number: "))
if re.match("^[0-9]{4,4}$", UserNum):
a = list(UserNum)
un.append(a)
numsys()
break
numval()