Last active
August 29, 2015 14:19
-
-
Save jonaslsaa/97a91f25522ccbc4c6d9 to your computer and use it in GitHub Desktop.
Name Generator with interchanging system for vowels and consonants. Review 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import re | |
| alphabet1 = ("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z") | |
| alphabet2 = ("b","c","d","f","g","h","j","k","l","m","n","p","q","r","s","t","v","w","x","z") | |
| alphabet3 = ("a","e","i","o","u","y") | |
| length = 7 # Length of word. | |
| c_length = 0 | |
| hasAlphabet3 = False | |
| length -= 1 | |
| name = "" | |
| # Generates first letter and capitalizes it. | |
| name += alphabet1[random.randint(0,25)].capitalize() | |
| c_length += 1 | |
| # Generates rest of letters based on first, if it is a vowel or a consonant. | |
| if name.endswith(alphabet3) == True: | |
| while c_length <= length: | |
| name += alphabet2[random.randint(0,19)] | |
| c_length += 1 | |
| if random.randint(0,1) == 1: | |
| name += alphabet3[random.randint(0,5)] | |
| else: | |
| name += alphabet2[random.randint(0,19)] | |
| c_length += 1 | |
| elif name.endswith(alphabet3) == False: | |
| while c_length <= length: | |
| name += alphabet3[random.randint(0,5)] | |
| c_length += 1 | |
| if random.randint(0,1) == 1: | |
| name += alphabet3[random.randint(0,5)] | |
| else: | |
| name += alphabet2[random.randint(0,19)] | |
| c_length += 1 | |
| print(name) #Prints generated word to screen. | |
| # Created By Vox |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment