Skip to content

Instantly share code, notes, and snippets.

@pejantantangguh
Created November 15, 2017 04:51
Show Gist options
  • Save pejantantangguh/0b45b18968fb08f171158e464b60c7e1 to your computer and use it in GitHub Desktop.
Save pejantantangguh/0b45b18968fb08f171158e464b60c7e1 to your computer and use it in GitHub Desktop.
To generate random number and put it in list, cross check the value of each list and only print number that are exist in list[a] and list[b]
import random
a = random.sample(range(50),20) #Sample won't have any duplicate value
b = random.sample(range(50),20)
#See number that are generated by a
print (a)
#See number that are generated by b
print (b)
c = []
for number in a:
if number in b:
c.append(number)
print (c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment