See this source code:
import random
import string
# Generate a random password of length 10
def generate_password(length):
characters = string.ascii_letters + string.digits + string.punctuation
return ''.join(random.choices(characters, k=length))
password = generate_password(10)
print(password)