Generating Password

Generate a password of specific length with no duplicate characters in the password

## random.sample(population, k) 
### Chooses k unique random elements from a population sequence or set.

import random

s = 'abcdefghijklmnopqrstuvwxyz01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()?'
length = 8
p =  ''.join(random.sample(s, length))
print (p)
ilQZkyHb

## random.choice(seq)
### Choose a random element from a non-empty sequence.

import string
import random

def pw_gen(size = 8, chars=string.ascii_letters + string.digits + string.punctuation):
    return ''.join(random.choice(chars) for _ in range(size))

print(pw_gen(int(input('How many characters in your password?'))))
How many characters in your password?5
XqqQ3

import string
import random

def pw_gen(size = 8, chars=string.ascii_letters + string.digits + string.punctuation):
    return ''.join(random.sample(chars, size))

print(pw_gen(int(input('How many characters in your password?'))))
How many characters in your password?5
?/m*e