좋아요, 그래서 모험 게임을 시작하고 프로그램에서 2 개의 대답 중에서 선택하도록하는 방법을 모르겠습니다.모험 게임에서 조건부로 입력을 처리하는 방법?
예 : 시작 하시겠습니까? input()
,하지만 그때 나는 플레이어가 중단하고 "끝내기"라고 말한 경우 또는 다음 질문으로 계속하기 위해 "예"라고 말한 경우 사이를 선택하는 방법을 모른다.
이 내 코드입니다 :
import os
import sys
import random
print("Welcome player!, we invite you to an andventure in our forests, but we warn you!, the monsters are luckng in every corner!")
print("We are going to ask you question for what you want to do and you will answer them by writing in the chat yes or no")
print("are you ready?")
a = input("yes or no?:")
# what goes next?
의'경우.lower() == "yes":'어떻게 해야할지 모르겠다면 더 많은 질문을 할 것입니다. 튜토리얼을 읽으십시오 : https://docs.python.org/3/tutorial /controlflow.html#if-statements – Keatinge
예를 들어 사용자가 '아니요'라고 답한 경우 프로그램에서 수행해야 할 작업을 결정해야합니다. 대부분의 도구에서 – cdarke
은'n','y' - 그리고'input ("Are you ready [N/y]?")'만 입력하면 기본 응답을 선호합니다.'- 상단'N'은 기본값을 보여줍니다 대답은'n'입니다.하지만'if'와'lower()'를 써야합니다. – furas