开发者

Rearranging a sequence

开发者 https://www.devze.com 2022-12-24 19:46 出处:网络
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:

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

精彩评论

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