Python Forum
Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Loops
#2
You need to store the answers from the user in a structure of data (so store somehow your enter_for_category in a data structure)

To put it clear, you can solve your exercise with the following:
for i in range(3):
    category = input("Enter a Category: ")
    # The next lines are a cry to suspend...
    a = input("Enter Something in that category: ")
    b = input("Enter Something in that category: ")
    c = input("Enter Something in that category: ")

    # Report the results:
    print(f"{category}: {a} {b} {c}")
So you see what you shall change... you need to replace the "a, b, c" with a data structure that allows you to fill it with a loop. Take a look to the dict and list in the python documentation.
Reply


Messages In This Thread
Loops - by alwillia - May-26-2018, 01:55 AM
RE: Loops - by killerrex - May-26-2018, 01:21 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020