#python #anaconda #jupyter-notebook #visual-code #html #css #javascript #http

제목중간참조 4번 질문입니다2021-04-18 22:23
작성자

def getResult(status):

    if status.find('_')==-1:

        return print('you win')

    else:

        return print('you lose')


def updateStatus(word, x, status):

    if x in word:

        for v in range(len(word)):

            if word[v]==x:

                status=status[:v]+x+status[v+1:]

            new_status=status

        return new_status

    else:

        new_status=status

        return new_status


def startGame(word):

    count=(len(word))

    status='_'*len(word)    

    a=input('{0}\n{1} chances. enter a letter : '.format(status,count))

    while count!=0:

        if '_' not in status:

            break

        count=count-1

        status=updateStatus(word,a,status)

        print(status)

        print(count,'chances',end='')

        a=input(' enter a letter : ')    

    return getResult(status)

6 chances enter a letter : M
HIPPOPOTAM__
5 chances enter a letter : U
HIPPOPOTAMU_
4 chances enter a letter : S
HIPPOPOTAMUS
3 chances enter a letter : ???
you win
None
4chances 에 S를 넣으면 you win이 뜨면서 바로 끝나야 하는데 뒤에 input 하나가 더나옵니다... 그리고 마지막에 none이 뜨는 이유를 모르겠어요ㅏ
댓글
이전중간고사 시험 관련 질문있습니다.2021-04-19
다음assertion error2021-04-18