From: lepickle Date: Thu, 6 Apr 2017 02:34:27 +0000 (+0800) Subject: Add "capitalize first letter" function to examples X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=31f6cc777054f4b48a37bb93453bcf405a9101a3;p=redacted-XKCD-password-generator.git Add "capitalize first letter" function to examples --- diff --git a/examples/example_import.py b/examples/example_import.py index c104db0..cb8282d 100644 --- a/examples/example_import.py +++ b/examples/example_import.py @@ -8,6 +8,13 @@ def random_capitalisation(s, chance): new_str.append(c.upper() if random.random() < chance else c) return "".join(new_str) +def capitalize_first_letter(s): + new_str = [] + s = s.split(" ") + for i, c in enumerate(s): + new_str.append(c.capitalize()) + return "".join(new_str) + words = xp.locate_wordfile() mywords = xp.generate_wordlist(wordfile=words, min_length=5, max_length=8) @@ -15,3 +22,5 @@ raw_password = xp.generate_xkcdpassword(mywords) for i in range(5): print(random_capitalisation(raw_password, i/10.0)) + +print(capitalize_first_letter(raw_password))