import random import string def get_random_string_for_student(student, length): # choose from all lowercase letter letters = string.ascii_letters + string.digits result_str = ''.join(random.choice(letters) for i in range(length)) print((student, result_str)) students = [ "e254275", "e223687", "e211024", "e209888", "e223725", "e209362", "e209898", "e230995", "e223743", "e223747", "e223749", "e223751", "e188126", "e209913", "e203608", "e233013", "e216982", "e217185", "e223780", "e194931", "e223783", "e254550", "e217203", "e217477", "e223786", "e231060", "e223795", ] for s in students: get_random_string_for_student(s, 15)