概要
「大石泉すき」Advent Calendar 2019にてExcel VBAでつくったものを、Pythonの勉強がてら焼き増ししただけのものです。
import random
STRING = '大石泉すき'
i = 0
output = ''
n = len(STRING)
max = n - 1
while output != STRING:
output = ''
for _ in range(n):
location = random.randint(0, max)
output += STRING[location]
print(output)
i += 1
print('「{}」が揃うまで{}回かかりました。'.format(STRING, i))
定数STRINGに好きな文字を入れて遊べます。