import random
def play_game(): print("숫자 맞추기 게임에 오신 것을 환영합니다!") print("저는 1부터 100까지의 숫자를 생각하고 있습니다.") secret_number = random.randint(1, 100) attempts = 0 while True: try: guess = int(input("당신의 예상을 써주십시오: ")) attempts += 1 print(f"{attempts}번째 시도") if guess < secret_number: if secret_number - guess < 5: print("아깝지만 당신의 예상은 제 숫자보다 낮습니다.") else: print("당신의 예상은 제 숫자보다 너무 낮습니다.") elif guess > secret_number: if guess - secret_number < 5: print("아깝지만 당신의 예상은 제 숫자보다 높습니다.") else: print("당신의 예상은 제 숫자보다 너무 높습니다.") else: print(f"축하합니다. 당신은 저의 숫자 {secret_number}를 {attempts}번째 예상에 맞추셨습니다.") if attempts < 11 and attempts != 1: print("칭호 '운 좋은 사람' 을(를) 얻었다!") elif attempts >= 11 and attempts < 21: print("칭호 '운 괜찮은 사람' 을(를) 얻었다!") elif attempts == 1: print("숨겨진 칭호 'Error Code 418' 을(를) 얻었다!!") break except ValueError: print("이 값은 정수가 아닙니다.")
if __name__ == "__main__": play_game()
If you need help, please contact our Help and Support team.
import random
def play_game():
print("숫자 맞추기 게임에 오신 것을 환영합니다!")
print("저는 1부터 100까지의 숫자를 생각하고 있습니다.")
secret_number = random.randint(1, 100)
attempts = 0
while True:
try:
guess = int(input("당신의 예상을 써주십시오: "))
attempts += 1
print(f"{attempts}번째 시도")
if guess < secret_number:
if secret_number - guess < 5:
print("아깝지만 당신의 예상은 제 숫자보다 낮습니다.")
else:
print("당신의 예상은 제 숫자보다 너무 낮습니다.")
elif guess > secret_number:
if guess - secret_number < 5:
print("아깝지만 당신의 예상은 제 숫자보다 높습니다.")
else:
print("당신의 예상은 제 숫자보다 너무 높습니다.")
else:
print(f"축하합니다. 당신은 저의 숫자 {secret_number}를 {attempts}번째 예상에 맞추셨습니다.")
if attempts < 11 and attempts != 1:
print("칭호 '운 좋은 사람' 을(를) 얻었다!")
elif attempts >= 11 and attempts < 21:
print("칭호 '운 괜찮은 사람' 을(를) 얻었다!")
elif attempts == 1:
print("숨겨진 칭호 'Error Code 418' 을(를) 얻었다!!")
break
except ValueError:
print("이 값은 정수가 아닙니다.")
if __name__ == "__main__":
play_game()