Zainzahid786's picture
Create app.py
e79cfea verified
raw
history blame contribute delete
840 Bytes
import streamlit as st
import random
# Title
st.title("✊🀚✌ Rock-Paper-Scissors Game")
st.write("Play against AI! Choose your move and see if you can beat the AI.")
# Choices
choices = ["Rock", "Paper", "Scissors"]
user_choice = st.selectbox("Select your move:", choices)
if st.button("Play"):
ai_choice = random.choice(choices) # AI selects a random move
st.write(f"πŸ€– AI chose: **{ai_choice}**")
# Determine the winner
if user_choice == ai_choice:
st.info("It's a tie! 🀝")
elif (user_choice == "Rock" and ai_choice == "Scissors") or \
(user_choice == "Paper" and ai_choice == "Rock") or \
(user_choice == "Scissors" and ai_choice == "Paper"):
st.success("πŸŽ‰ You win!")
else:
st.error("😒 AI wins!")
# Footer
st.sidebar.write("πŸš€ Have fun playing!")