-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
39 lines (29 loc) · 1.09 KB
/
test.py
File metadata and controls
39 lines (29 loc) · 1.09 KB
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
def add_expense():
while True:
description = input("What is the description of your expense?\n").strip()
if not description:
print("########################")
print("No description provided")
print("########################")
continue
while True:
try:
amount = float(input("What is the amount of your expense? \n"))
if not amount:
print("No amount provided")
continue
break
except ValueError:
print("Invalid amount. Please enter a numeric value.")
continue
except IOError:
print("Error reading input. Please try again.")
continue
except Exception as e:
print(f"An unexpected error occurred: {e}")
continue
print(f"Expense Description: {description}")
print(f"Expense Amount: {amount}")
if __name__ == '__main__':
add_expense()
# todo: SAVE EXPENSE TO CSV