Coverage for e27_makepw.py : 100%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/env python3
3"""Solution to chapter 6, exercise 27: makepw"""
5import random
8def create_password_generator(characters):
9 """This function takes a string as input.
11It returns a function that, when invoked with an
12integer argument, returns a string containing
13a random selection from "characters", of length
14"length".
15"""
16 def create_password(length):
17 output = []
19 for i in range(length):
20 output.append(random.choice(characters))
21 return ''.join(output)
22 return create_password