File size: 710 Bytes
0d705b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st

# App title
st.title("πŸ“ Simple To-Do List")

# Initialize task list
if "tasks" not in st.session_state:
    st.session_state.tasks = []

# Add new task
new_task = st.text_input("Add a task:")
if st.button("Add"):
    if new_task.strip():
        st.session_state.tasks.append(new_task)
        st.success(f"Task added: {new_task}")
    else:
        st.warning("Task cannot be empty.")

# Display tasks
st.subheader("Your Tasks:")
if st.session_state.tasks:
    for task in st.session_state.tasks:
        st.write(f"- {task}")
else:
    st.write("πŸŽ‰ No tasks yet!")

# Clear all tasks
if st.button("Clear All"):
    st.session_state.tasks = []
    st.warning("All tasks cleared!")