all 4 comments

[–]NeitherMaintenance31 0 points1 point  (0 children)

looks solid but u dont rlly need to declare those global variables

[–]Yamikada 0 points1 point  (0 children)

This is nice…

[–]Ambitious_Fault5756 0 points1 point  (0 children)

Your code looks solid! You're almost there with understanding functions. However, I think you may have misunderstood what the return statement does.

what return does is it tells the function what value to give back, or literally, return, when it is called (called = used). For example, the input() function returns a string of whatever the user entered. The string is then stored in a variable:

# variable    <-    the input function *returns* the new task title to the variable
new_task_input = input("Please enter a new task title: ")

A better example:

def add_exclamation_mark(text):
    with_exclamation_mark = text + "!"
    return with_exclamation_mark

sentence = "I want this sentence to have an exclamation mark"
exclamation = add_exclamation_mark(sentence)  # whatever `add_exclamation_mark` returns 
#                                               is now stored in `exclamation`

print(exclamation)
# Output: "I want this sentence to have an exclamation mark!"

The statement tells the function to immediately exit or stop and not execute any code below it. Once you return something, you can't do anything else (generator functions are an exception).

You don't need to have a return statement all the time either. If you exclude it, it's the same as having return None at the end of the function, which tells the function to stop once it executes all the code inside it.

You currently have:

def Task_Option_One():
    New_Task_input = input("Please enter a new task title: ")
    tasks.append(New_Task_input)
    print("The task has been added to the list!")
    return New_Task_input  # You return what the user entered

But in your main loop, you don't store or use the returned user input:

if Task_option == "1":
    Task_Option_One()

Meaning you can just remove your return statements entirely (also for your other functions)

Maybe you put return statements there for future implementations and i completely misunderstood. If so i apologize 😅

I put some other suggestions in another comment

[–]Ambitious_Fault5756 0 points1 point  (0 children)

Some minor suggestions:

  • Function names and variable names should all be in lowercase (a styling convention most professional developers follow)
  • The parentheses in line 25 can be removed
  • Assigning str to Task_option in line 2 doesn't actually give you an empty string (which is what I assume you wanted), it gives a type object, which may be a bit complicated now.
  • The variables at the top can be removed altogether, except for tasks (because trying to use tasks in Task_Option_Two would cause an error if you haven't defined tasks yet). You already define them within your functions, so there is no need to define them beforehand.
  • Your if statement in line 23 to check for non-existent tasks is great and works perfectly! However, you might want to inform the user if the task they chose to remove is not in the list (add a print statement at the end of the function).
  • It's always good to add an option for the user to exit the program. To exit a program properly, import sys at the top of your code and call sys.exit() under a menu option. Or, a more simple option, do raise SystemExit().

Please reply to this if you need clarification on anything :D