Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import random | |
| st.set_page_config(page_title="Rock Paper Scissors", page_icon="✊") | |
| st.title("Rock Paper Scissors") | |
| st.write("Play against the computer") | |
| choices = ["Rock", "Paper", "Scissors"] | |
| user_choice = st.radio("Choose one:", choices) | |
| if st.button("Play"): | |
| computer_choice = random.choice(choices) | |
| st.write(f"You chose: {user_choice}") | |
| st.write(f"Computer chose: {computer_choice}") | |
| if user_choice == computer_choice: | |
| st.success("It's a tie") | |
| elif ( | |
| (user_choice == "Rock" and computer_choice == "Scissors") or | |
| (user_choice == "Paper" and computer_choice == "Rock") or | |
| (user_choice == "Scissors" and computer_choice == "Paper") | |
| ): | |
| st.success("You win") | |
| else: | |
| st.error("Computer wins") | |