Create a complex random password with Python
import random, string
def passwd_gen(length):
letters = string.ascii_letters
digits = string.digits
special_char = ['!','@','#','$','%','^','&','*']
combination = letters + digits + str(special_char)
for i in range(int(length)-1):
final_string = ''.join(random.sample(combination,length))
if " " in final_string:
final_string=final_string.replace(" ","$")
print("Password Generated as : {0}".format(final_string))
passwd_gen(12)