import random temp = '' for i in range(4): red1 = random.randrange(0,4) if red1 == 1 or red1 == 3: temp += str(red1) else: red = random.randrange(65,91) c = chr(red) temp += c print(temp)