Created
November 15, 2017 04:51
-
-
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]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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