What would be a good way of modifying this code to add in one ‘*’ character per hand? Would you use weights?? Or would you set x to the character I am wanting once per pass of the loop? Any insight on this would be appreciated.
More information is necessary. Do you want a fixed number of vowels and consonants and add in one asterisk? Or do you want the asterisk to replace one of your calculated numbers of vowels and consonants?
The first is simple. Do the pick you’re doing and just stick an asterisk on the end.
I guess maybe I was just overcomplicating it. I just feel like this isn’t the best code but works for my use currently. It gives 2 vowels 1 asterisk.
hand={}
num_vowels = int(math.ceil(n / 3))
for i in range(num_vowels):
x = '*'
if x not in hand:
hand[x] = hand.get(x, 0) + 1
else:
x = random.choice(VOWELS)
hand[x] = hand.get(x, 0) + 1