def dealHand(n):
"""
Returns a random hand containing n lowercase letters.
At least n/3 the letters in the hand should be VOWELS.
Hands are represented as dictionaries. The keys are
letters and the values are the number of times the
particular letter is repeated in that hand.
n: int >= 0
returns: dictionary (string -> int)
"""
hand={}
numVowels = n / 3
for i in range(numVowels):
x = VOWELS[random.randrange(0, len(VOWELS))]
hand[x] = hand.get(x, 0) + 1
for i in range(numVowels, n):
x = CONSONANTS[random.randrange(0,len(CONSONANTS))]
hand[x] = hand.get(x, 0) + 1
return hand
这个函数是我必须做的一个文字游戏的一部分,它被包含在一些帮助函数中以帮助开始,我的问题是它返回的字母不是很随机,有很多重复的字母,比如: a a c c b e e g j j m m m o o r t v y x
,我是只是想知道是否有可能获得一组更随机的字符?