편집 기록

편집 기록
  • 프로필 nowp님의 편집
    날짜2022.06.11

    break outside loop


    import random
    
    while True:
        name=input('당신의 이름은 무엇입니까?:')
        print(name,'님','안녕하세요?')
    
        dice=random.randint(1,6)
        if dice==1:
            print('ㅇ.')
        elif dice==2:
            print('ㄴ.')
        elif dice==3:
            print('ㄹ.')
        elif dice==4:
            print('ㅎ.')
        elif dice==5:
            print('ㄱ.')
        else:
            print('ㅂ.')
    print('감사합니다.')
    
    input('시스템을 중지하시겠습니까?')
    
    if answer=='Y'or'y':
        break
    elif answer=='N'or'n':
        continue
    
    

    코드는 이렇게 정했고, answer가 'Y'또는'y'를 눌러야만 break를 하고 싶은데 제목에 써져 있는 오류가 계속 반복이 되어서요. 어느 부분을 어떻게 수정해야 할까요..?

  • 프로필 왕초보님의 편집
    날짜2022.06.11

    break outside loop 해결해주세요 ㅠ


    import random
    
    while True:
        name=input('당신의 이름은 무엇입니까?:')
        print(name,'님','안녕하세요?')
    
        dice=random.randint(1,6)
        if dice==1:
            print('ㅇ.')
        elif dice==2:
            print('ㄴ.')
        elif dice==3:
            print('ㄹ.')
        elif dice==4:
            print('ㅎ.')
        elif dice==5:
            print('ㄱ.')
        else:
            print('ㅂ.')
    print('감사합니다.')
    
    input('시스템을 중지하시겠습니까?')
    
    if answer=='Y'or'y':
        break
    elif answer=='N'or'n':
        continue
    
    

    코드는 이렇게 정했고, answer가 'Y'또는'y'를 눌러야만 break를 하고 싶은데 제목에 써져 있는 오류가 계속 반복이 되어서요 ㅠㅠ 어느 부분을 어떻게 수정해야 할까요..?