끝말잇기1 [Python] [3] 텍스트 파일(끝말잇기 게임) 1. 끝말잇기 텍스트 파일을 다루는 방법을 배워봤다. txt 파일을 파이썬 파일과 같은 곳에 두면 텍스트 파일의 내용을 사용할 수 있다! # 끝말잇기 게임 import random words = open('korean_words.txt', encoding='utf-8').read().split() # txt 파일에는 1805개의 단어가 들어있다 def isOkay(word): # 두음 법칙을 고려(?)했다 s1 = '냥녀뇨니라락란래량려렷로론뢰료루류륜리' s2 = '양여요이나낙난내양여엿노논뇌요누유윤이' tt = str.maketrans(s1, s2) return word[-1:].translate(tt) def game(): start = random.choice(words) # 상대가 먼저 시작 word.. 2023. 12. 29. 이전 1 다음