Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,12 @@ def main():
|
|
7 |
|
8 |
st.write("Choose Rock, Paper, or Scissors and play against the computer!")
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
# User input
|
11 |
user_choice = st.selectbox("Your choice:", ["Rock", "Paper", "Scissors"])
|
12 |
|
@@ -19,20 +25,4 @@ def main():
|
|
19 |
st.write(f"Computer chose: {computer_choice}")
|
20 |
|
21 |
# Determine the winner
|
22 |
-
if user_choice ==
|
23 |
-
result = "It's a tie!"
|
24 |
-
elif (
|
25 |
-
(user_choice == "Rock" and computer_choice == "Scissors") or
|
26 |
-
(user_choice == "Paper" and computer_choice == "Rock") or
|
27 |
-
(user_choice == "Scissors" and computer_choice == "Paper")
|
28 |
-
):
|
29 |
-
result = "You win!"
|
30 |
-
else:
|
31 |
-
result = "You lose!"
|
32 |
-
|
33 |
-
# Display the result
|
34 |
-
st.write(result)
|
35 |
-
|
36 |
-
# Run the app
|
37 |
-
if __name__ == "__main__":
|
38 |
-
main()
|
|
|
7 |
|
8 |
st.write("Choose Rock, Paper, or Scissors and play against the computer!")
|
9 |
|
10 |
+
# Initialize session state for points
|
11 |
+
if "user_points" not in st.session_state:
|
12 |
+
st.session_state.user_points = 0
|
13 |
+
if "computer_points" not in st.session_state:
|
14 |
+
st.session_state.computer_points = 0
|
15 |
+
|
16 |
# User input
|
17 |
user_choice = st.selectbox("Your choice:", ["Rock", "Paper", "Scissors"])
|
18 |
|
|
|
25 |
st.write(f"Computer chose: {computer_choice}")
|
26 |
|
27 |
# Determine the winner
|
28 |
+
if user_choice == computer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|