-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
360799e
commit 8ece00b
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
#Functions | ||
|
||
#Greets the User | ||
def greeting(): | ||
name = input("What is your name? ") | ||
print(f"Hello, {name}!") | ||
|
||
#Asks user to add task | ||
def add_task(tasks): | ||
task = input("What task would you like to add? ") | ||
tasks.append(task) | ||
print(f"Task '{task}' has been added to your todo list.") | ||
|
||
#Shows user current items in todo list | ||
def view_list(tasks): | ||
if not tasks: | ||
print("Your todo list is empty.") | ||
else: | ||
print("Here is your current todo list:") | ||
for i in tasks: | ||
print(" - {}".format(i)) | ||
|
||
#The main program | ||
def main(): | ||
tasks = [] | ||
greeting() | ||
while True: | ||
print("Please choose an option:") | ||
print("1. Add a task") | ||
print("2. View list") | ||
print("3. Exit") | ||
choice = input("Enter your choice (1, 2, or 3): ") | ||
if choice == "1": | ||
add_task(tasks) | ||
elif choice == "2": | ||
view_list(tasks) | ||
elif choice == "3": | ||
print("Goodbye!") | ||
break | ||
else: | ||
print("Invalid choice, please try again.") | ||
|
||
#Initiates Programme | ||
main() |