import random def v_code(): code = '' for i in range(5): # if i == random.randint(0,5): # add = random.randrange(10) # else: # add = chr(random.randint(65,91)) add =random.choice([random.randrange(10),chr(random.randint(65,91))]) code += str(add) return code a = v_code() print(a)