Spaces:
Sleeping
Sleeping
I added buttons
Browse files
app.py
CHANGED
@@ -28,19 +28,32 @@ def guess():
|
|
28 |
st.session_state.max_attempts = 5
|
29 |
|
30 |
st.write(f"Here's the description for the person: {', '.join(st.session_state.description)}")
|
31 |
-
|
|
|
32 |
guess = st.text_input("Who Do You Think It Is??")
|
|
|
|
|
33 |
|
34 |
-
if
|
|
|
35 |
st.success(f"CONGRATULATIONS!!! YOU GUESSED IT CORRECTLY! IT IS {st.session_state.chosen_name}")
|
36 |
st.stop() # Stop the app after a correct guess
|
37 |
|
38 |
-
|
39 |
st.warning("That's Not Correct. Please Try Again.")
|
40 |
-
|
41 |
st.error(f"Sorry, You're Out Of Attempts. The Correct Answer Was {st.session_state.chosen_name}")
|
42 |
st.stop() # Stop the app after the game ends
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
|
44 |
st.session_state.attempts += 1
|
45 |
|
|
|
|
|
46 |
guess()
|
|
|
28 |
st.session_state.max_attempts = 5
|
29 |
|
30 |
st.write(f"Here's the description for the person: {', '.join(st.session_state.description)}")
|
31 |
+
|
32 |
+
a, b = st.columns(2)
|
33 |
guess = st.text_input("Who Do You Think It Is??")
|
34 |
+
submit = a.button("submit")
|
35 |
+
clear = b.button("clear")
|
36 |
|
37 |
+
if submit:
|
38 |
+
if guess.lower() == st.session_state.chosen_name.lower():
|
39 |
st.success(f"CONGRATULATIONS!!! YOU GUESSED IT CORRECTLY! IT IS {st.session_state.chosen_name}")
|
40 |
st.stop() # Stop the app after a correct guess
|
41 |
|
42 |
+
if st.session_state.attempts < st.session_state.max_attempts - 1:
|
43 |
st.warning("That's Not Correct. Please Try Again.")
|
44 |
+
else:
|
45 |
st.error(f"Sorry, You're Out Of Attempts. The Correct Answer Was {st.session_state.chosen_name}")
|
46 |
st.stop() # Stop the app after the game ends
|
47 |
+
|
48 |
+
if clear:
|
49 |
+
del st.session_state.choosen_name
|
50 |
+
del st.session_state.description
|
51 |
+
del st.session_state.attempts
|
52 |
+
return
|
53 |
+
|
54 |
|
55 |
st.session_state.attempts += 1
|
56 |
|
57 |
+
|
58 |
+
|
59 |
guess()
|