본문 바로가기
코딩

랜덤으로 운명을 점쳐주는 운세게임 코드를 만들어보자.

by 노마드랩스 2023. 2. 16.
728x90
반응형

이 코드는 사용자는 자신의 이름을 묻고 개인화된 운세가 생성되어 화면에 표시됩니다.

 

운세는 5가지를 넣었습니다.

 

import random

# List of pre-determined fortunes
fortunes = [
    "A beautiful, successful, and fulfilling future awaits you.",
    "You will soon meet someone new and special.",
    "You will receive good news and financial gains soon.",
    "Travel and new experiences are in your future.",
    "You will find love and happiness in the near future."
]

# Welcome message
print("Welcome to the Fortune Teller!")

# Ask for user's name
name = input("What is your name? ")

# Generate a random fortune
fortune = random.choice(fortunes)

# Print the fortune
print("\nHello, " + name + "! Your fortune is:")
print("\n" + fortune + "\n")

728x90
반응형

댓글