开发者

Rearranging a sequence

I'm have trouble rearranging sequences so the amount of letters in the given original sequence are the same in the random generated sequences. For example:

If i have a string 'AAAC' I n开发者_StackOverfloweed that string rearranged randomly so the amount of A's and C's are the same.


import random
chars = list("AAAC")
random.shuffle(chars)
return ''.join(chars)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜