Python-从列表中随机更改字符串中的文本

我想编写一个循环函数,遍历我的每个字母

original = ['ABCD', 'DCBA', 'AAAA', 'AABB']
letters  = ['A', 'B', 'C', 'D'] 

p = 1

for o in original: # loop through the original list
    for i in range(0,len(o)): # loop through each letter in selected list

        if random.randint(1,10) == p: #if this gives me the probability that is met
        # I want to change the current letter on the current index to 
        # something else different from the letter list by random (maybe random.choice)

我是python的新手,请您指教。 我不想使用类或任何其他库,但请随意

评论