Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| from datetime import datetime, date | |
| st.set_page_config(page_title="Age Calculator", page_icon="π") | |
| st.title("π Age Calculator") | |
| st.write("Enter your date of birth to calculate your age.") | |
| dob = st.date_input("Select your Date of Birth", min_value=date(1900, 1, 1), max_value=date.today()) | |
| if st.button("Calculate Age"): | |
| today = date.today() | |
| age_years = today.year - dob.year - ((today.month, today.day) < (dob.month, dob.day)) | |
| st.success(f"You are {age_years} years old.") | |