Spaces:
Running
Running
eaglelandsonce
commited on
Commit
•
9b96db1
1
Parent(s):
8b23c16
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
# Streamlit application
|
4 |
+
st.title("Sum Calculator")
|
5 |
+
|
6 |
+
# Input for user to enter numbers in the specified format
|
7 |
+
user_input = st.text_input("Enter numbers to add (e.g., 3+9+12+...):")
|
8 |
+
|
9 |
+
# Check if input is provided
|
10 |
+
if user_input:
|
11 |
+
try:
|
12 |
+
# Parse the input and calculate the sum
|
13 |
+
numbers = [int(num.strip()) for num in user_input.split("+")]
|
14 |
+
total_sum = sum(numbers)
|
15 |
+
st.write(f"The sum of the numbers is: {total_sum}")
|
16 |
+
except ValueError:
|
17 |
+
st.write("Please enter a valid sequence of numbers separated by '+' signs.")
|
18 |
+
else:
|
19 |
+
st.write("Please enter numbers in the format 3+9+12+...")
|