File size: 1,949 Bytes
674e800
 
 
 
f7c14ac
674e800
 
 
f7c14ac
674e800
 
 
 
 
 
 
 
 
 
 
 
f7c14ac
 
 
 
 
 
 
674e800
f7c14ac
674e800
f7c14ac
674e800
f7c14ac
 
 
674e800
f7c14ac
 
 
 
 
674e800
f7c14ac
674e800
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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()