Sep-17-2017, 04:02 PM
It works like this:
1 Vowel, 1 Consonant, 1 Vowel, 1 Consonant.. (So It sounds like a word..) VCVCVC
Vowels: A, E, I, O, U
Consonants: B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, X, Z / W, Y, Q..
This is what I got so far:
Now what's left is removing Q&Y&W out of consonants and make letters not repeat. Can somebody help me with this?
1 Vowel, 1 Consonant, 1 Vowel, 1 Consonant.. (So It sounds like a word..) VCVCVC
Vowels: A, E, I, O, U
Consonants: B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, X, Z / W, Y, Q..
This is what I got so far:
1 2 3 4 5 6 7 8 9 10 |
import random import string VOWELS = list ( "AEIOU" ) CONSONANTS = list ( set (string.ascii_uppercase) - set (VOWELS)) def generate_word(length = 5 ): return "".join(random.choice([VOWELS, CONSONANTS][_ % 2 ]) for _ in range (length)) print (generate_word( 4 )) |