Python 파이썬 2019. 10. 9. 13:08

UP & DOWN 게임

1~100 사이의 임의의 숫자를 생성합니다.
사용자가 추측한 후 숫자를 입력하면, 생성된 숫자와 비교하여 up 또는 down을 출력합니다. 
사용자가 생성된 숫자를 맞출때까지 반복해서 동작하도록 구현합니다.

 

[결과]

[코드]

import random
guess = random.randint(1, 100) 
print("숫자(1~100)")
user = int(input())
while (guess is not user):
    if guess>user:
        print("up")
        user = int(input())
    elif guess        print("down") 
        user = int(input())
else:
    print("정답")
    

posted by 스노(Snow)
: