#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http 제목중간참조문제 4번2021-04-16 19:02작성자수강생#영어단어 맞추기 함수def getResult(status): if status.count('_') == 0: return 'You win' else : return 'You lose'def updateStatus(word,x,status): if x in word: cou = word.count(x) fin = 0 for j in range(1,cou+1): fin = word.find(x,fin+1) new_status = status[:fin]+x+status[fin+1:] else: new_status = status print(new_status) return new_statusdef startGame(word): status="_"*len(word) count = len(word) print(status) print(count,'chances.') for i in range(1,count+1): x = input("Enter the letter: ") updateStatus(word,x,status) print(count-i,'chances.') if word == status: return 'You win' print(getResult(status)) return getResult(status) startGame('HELLO')이런식으로 코드를 짜면 x에 H를 넣었을 때 new_status=H____으로 바뀌지만 그뒤 다시x에 E를 넣었을 경우 new_status=_E___로 나옵니다. status가 계속_____로 고정되어있어서 그런거 같은데 status=new_status를 updateStatus함수 끝쪽에 넣으면 startGame함수로 넘어오면서 다시 _____로 바뀌고 statGame함수에 넣으면 정의되지않은 변수라고 나오는데 어떻게 해야할까요? 목록수정삭제답변글쓰기 댓글 [3] 댓글작성자(*)비밀번호(*)내용(*) 댓글 등록 더보기이전step 9 나무 만들기ㅂㅈㄷ2021-04-17다음중간고사관련질문수강생12021-04-16 Powered by MangBoard | 워드프레스 쇼핑몰 망보드