본문 바로가기
카테고리 없음

25-06-12 랜덤 숫자 맞추기

by 지식 프로파일러 2025. 6. 12.

python

 

from random import randint

print("Welcome to Python Casino!")
pc_choice = randint(1, 100) 

playing = True
count = 5
while playing and count >= 1: 
  user_choice = int(input("choose number (1-100): "))
  if user_choice == pc_choice:
      print("you won")
      playing = False
  elif user_choice > pc_choice:
      print("lower!")
      count -= 1
  elif user_choice < pc_choice:
      print("higher")
      count -= 1

if count == 0:
  print("you lose")