random_generator.py 546 B

12345678910111213141516171819
  1. import random
  2. # !!!!!!!!!!!!!!!!! NOT UPDATED !!!!!!!!!!!!!!!!!!!!!
  3. # def get_random_dict_elements(dict_, count):
  4. # random_dict = {}
  5. # for i in range(0, count):
  6. # key, value = random.choice(list(dict_.items()))
  7. # random_dict[key] = value
  8. # return random_dict
  9. def get_random_list_elements(list_, count):
  10. list_2 = list_.copy()
  11. random_list = []
  12. for i in range(0, min(count,len(list_2))):
  13. elem = random.choice(list_2)
  14. random_list += [elem]
  15. list_2.remove(elem)
  16. return random_list