import random
A = ['a', 'b', 'c', 'd', 'e']
B = []
count = 1
while True :
B.append(random.choice(A))
print(B)
repeat = B.count('a')
if repeat >= 2 :
print("Waring!!!")
if count >= 10 :
break
count += 1
I wrote upper code. but I want add some options.
- I want create B as two-dimensional list having 5 row. if count 6, for example, code can prints B = [[a, b, c, a, b], [e]]
- I want to print a Warning message if there is a letter occuring two or more in times in each column. for example, if B = [[a, b, c, a, b], [e]] in count 6, code will prints 'Warning, a, b duplicate in 1 column'. or if B = [[a, b, c, a, b], [e, e, a, d, e]] in count 10, code will prints 'Warning, a, b duplicated in 1 column' and 'Waring, e duplicate in 2 column.'.
I always appreciate your help.