Skip to content

Instantly share code, notes, and snippets.

@neerajvashistha
Last active December 20, 2018 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neerajvashistha/8ae791b2afbdcad2bb46107c69986514 to your computer and use it in GitHub Desktop.
Save neerajvashistha/8ae791b2afbdcad2bb46107c69986514 to your computer and use it in GitHub Desktop.
import random
random.seed(1000)
keys = 'KUL_EAT'
old_list =['KUL_EAT_0','KUL_EAT_1','KUL_EAT_2','KUL_EAT_3','KUL_EAT_4','KUL_EAT_5','KUL_EAT_6','KUL_EAT_7','KUL_EAT_8','KUL_EAT_9','KUL_EAT_10','KUL_EAT_11','KUL_EAT_12','KUL_EAT_13','KUL_EAT_14','KUL_EAT_15', 'KUL_EAT_43']
pool = random.sample(range(50), 40)
def randomGenerator(keys,pool,old_list):
'''
keys : sequence start
pool : global sequence list unused
old_list : gloabl sequence list used
'''
pool = [i for i in pool if not keys+'_'+str(i) in old_list]
print(pool)
random_no = random.choice(pool)
pool.remove(random_no)
value = keys+'_'+str(random_no)
old_list.append(value)
return value
for j in range(10):
for i in randomGenerator(keys,pool,old_list):
print i
print(old_list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment