파이썬으로 대석천 취미를 통일할 수 있는 게임을 몇 번 만들어봐요.

2551 단어 Python3

개요


"돌샘이 좋아요". Advent Calendar 2019.엑셀 VBA로 만든 거. 그냥 파이썬 공부하는 김에 추가했어요.
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))

상수 스트링에 좋아하는 글자를 넣고 놀 수 있다.

결과


좋은 웹페이지 즐겨찾기