You can download this code by clicking the button below.
This code is now available for download.
Generates a unique ID with a specified prefix and length.
Technology Stack : random, string
Code Type : Function
Code Difficulty : Intermediate
def unique_id_generator(prefix="ID", length=8):
import random
import string
def _random_string(length):
letters = string.ascii_letters + string.digits
return ''.join(random.choice(letters) for i in range(length))
return f"{prefix}_{_random_string(length)}"