A problem in viewing the output!

Joined
Jun 14, 2024
Messages
2
Reaction score
0
Hi, I am creating a weekly planner, that takes the goals of each day in a week and then views them to the user.

#Code :-

goal=[]

def main_display():
print("Weekly Planner")
print("1, Set Goals")
print("2, View Goals")
print("3, Exit")

def set_goals(goals):
days_in_week=["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
for day in days_in_week:
goals = input(f"{day}, ")
goal.append(goals)
print("entered goal successfully")
main_menu()

def view_goals(goals):
days_in_week=["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
if not goals:
print("No goals entered yet")
else:
print("Weekly Plan")
#for day in (days_in_week):
print(f"{days_in_week} : {goal}")
main_menu()

def main_menu():
main_display()
choice=input("Enter choice 1/2/3:")
if choice == '1':
set_goals(goal)
print(goal)
elif choice== '2':
view_goals(goal)
elif choice== '3':
print("Exiting the Planner!")
else:
print("Invalid number. Try again")
main_menu()

def main():
goals = {}
main_menu()

if name == "main":
main()

_________________________________________________________________________

The output I desire is:-
Monday: <goal>
Tuesday: <goal>, and soo on

The output I am getting:- ['read', 'read', 'read', 'read', 'read', 'read', 'read', 'read', 'read', 'read', 'read', 'read', 'read', 'die', 'read', 'study', 'code', 'study', 'project', 'project', 'rest']

is a list of all inputs.

how to solve it?
 
Joined
Jul 4, 2023
Messages
406
Reaction score
47
Have you tried this way for example?
[ working code on-line ]
Python:
import os, time, sys

def clearConsole():
    os.system('cls' if os.name in ('nt', 'dos') else 'clear')

# global variables
DAYS_IN_WEEK = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ]
goals = []


def main_display():
    clearConsole()
    print("Weekly Planner")
    print("1, Set Goals")
    print("2, View Goals")
    print("3, Exit")

def message_display(message):
    print(f"\n:: {message}")
    time.sleep(3)
    main_menu()

def set_goals():
    print()
    for day in DAYS_IN_WEEK:
        print(f"{day}, ", end="")
        goal = (input()).strip(' \t\n\r')
        if goal:
            goals.append(f"{day}, {goal}")
            sys.stdout.write("\033[F")  # Move the cursor up one line
            print(f"{day}, {goal} :: entered goal successfully")

def view_goals():
    if not goals:
        message_display("No goals entered yet")
    else:
        print("\nWeekly Plan")
        for goal in goals:
            print(goal)

def main_menu():
    main_display()
    choice=input("Enter choice 1/2/3: ")
    if choice == "1":
        set_goals()
        input("\nPress Enter to continue ...")
    elif choice== "2":
        view_goals()
        input("\nPress Enter to continue ...")
    elif choice== "3":
        message_display("Exiting the Planner!")
        # your code for exit action
    else:
        message_display("Invalid number. Try again")
    main_menu()

def main():   
    main_menu()


if __name__ == "__main__":
    main()

1718370359611.png
 
Joined
Jun 14, 2024
Messages
2
Reaction score
0
Have you tried this way for example?
[ working code on-line ]
Python:
import os, time, sys

def clearConsole():
    os.system('cls' if os.name in ('nt', 'dos') else 'clear')

# global variables
DAYS_IN_WEEK = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ]
goals = []


def main_display():
    clearConsole()
    print("Weekly Planner")
    print("1, Set Goals")
    print("2, View Goals")
    print("3, Exit")

def message_display(message):
    print(f"\n:: {message}")
    time.sleep(3)
    main_menu()

def set_goals():
    print()
    for day in DAYS_IN_WEEK:
        print(f"{day}, ", end="")
        goal = (input()).strip(' \t\n\r')
        if goal:
            goals.append(f"{day}, {goal}")
            sys.stdout.write("\033[F")  # Move the cursor up one line
            print(f"{day}, {goal} :: entered goal successfully")

def view_goals():
    if not goals:
        message_display("No goals entered yet")
    else:
        print("\nWeekly Plan")
        for goal in goals:
            print(goal)

def main_menu():
    main_display()
    choice=input("Enter choice 1/2/3: ")
    if choice == "1":
        set_goals()
        input("\nPress Enter to continue ...")
    elif choice== "2":
        view_goals()
        input("\nPress Enter to continue ...")
    elif choice== "3":
        message_display("Exiting the Planner!")
        # your code for exit action
    else:
        message_display("Invalid number. Try again")
    main_menu()

def main():  
    main_menu()


if __name__ == "__main__":
    main()

View attachment 2834
This works!! Thank you so much for the help!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,818
Messages
2,569,727
Members
45,664
Latest member
Phil79581

Latest Threads

Top