K0RB1's picture
save all changes
f7c14ac
raw
history blame
1.95 kB
import random
import streamlit as st
st.title("Welcome To Person Guessing Game!!")
st.header("I will describe a person and you need to guess who it is by their characteristics")
st.write("Here Is Your Choices: Gian, Kirby, Francys, JK, Cielo, Arki, Basti, Mico, and Jhay.")
def guess():
people = {
"Gian": ["Smart", "small", "hyper"],
"Kirby": ["small", "loyal", "Loves badminton"],
"Francys": ["serious", "smart", "quiet"],
"JK": ["tall", "foot fetish", "talkative"],
"Cielo": ["quiet", "Loves to watch peppapig", "Enjoys editing"],
"Arki": ["talkative", "Loves blue by yung kai", "enjoys coding"],
"Basti": ["Music lover", "tall", "Enjoys jamming with friends"],
"Mico": ["smart", "Good at editing", "Enjoys coding"],
"Jhay": ["kind", "Always making others laugh", "Loves to make friends laugh"]
}
if 'chosen_name' not in st.session_state:
names = list(people.keys())
index = random.randint(0, len(names) - 1)
st.session_state.chosen_name = names[index]
st.session_state.description = people[st.session_state.chosen_name]
st.session_state.attempts = 0
st.session_state.max_attempts = 5
st.write(f"Here's the description for the person: {', '.join(st.session_state.description)}")
guess = st.text_input("Who Do You Think It Is??")
if guess.lower() == st.session_state.chosen_name.lower():
st.success(f"CONGRATULATIONS!!! YOU GUESSED IT CORRECTLY! IT IS {st.session_state.chosen_name}")
st.stop() # Stop the app after a correct guess
if st.session_state.attempts < st.session_state.max_attempts - 1:
st.warning("That's Not Correct. Please Try Again.")
else:
st.error(f"Sorry, You're Out Of Attempts. The Correct Answer Was {st.session_state.chosen_name}")
st.stop() # Stop the app after the game ends
st.session_state.attempts += 1
guess()