Add "capitalize first letter" function to examples
authorlepickle <redacted>
Thu, 6 Apr 2017 02:34:27 +0000 (10:34 +0800)
committerlepickle <redacted>
Thu, 6 Apr 2017 02:34:27 +0000 (10:34 +0800)
examples/example_import.py

index c104db05719dbc9550437ebeeb16bac01c3b4db5..cb8282db52687f1d29a567f40e2164000aa660af 100644 (file)
@@ -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))
git clone https://git.99rst.org/PROJECT