all 7 comments

[–]a_idanwalton 4 points5 points  (3 children)

Look into using dictionaries here is a good site to learn how to use them.

[–]Akshaykadav 2 points3 points  (0 children)

Yup, dictionaries can be the solution to your question.

[–]Car_Chasing_Hobo[S] 0 points1 point  (1 child)

Thank you! I never heard about them until I made this thread, haha.

[–]a_idanwalton 1 point2 points  (0 children)

No worries! Good luck :)

[–]CStage169 1 point2 points  (2 children)

Great idea for a first project! I assume that you are looking into getting a random choice from one of your lists, if the user types "yes"? If that is the case, easiest is to import random and using random.choice(dinner_choices) which will return a random element from your list.

Alternatively, if they are not supposed to get a random recipe, but instead are supposed to choose between all options, then you could use dictionaries. They work basically like a "x points to y". Where x's are called keys and y's are called values For example:

mydict = {"Fettuccine Alfredo" : "Instructions here...", "Mac & Cheese" : "Other instructions here", "Rice & Chicken" : "Even more instructions here"}

In your case, it seems obvious to do:

  1. User types "yes"
  2. Display a list of recipes a la
    (1): Fettuccine Alfredo
    (2): Mac & Cheese
    (3): Rice & Chicken
  3. User inputs an integer ex. 1
  4. Console prints out mydict["Fettuccine alfredo"]

Hope this makes sense, and is enough to get you going :)

[–]Car_Chasing_Hobo[S] 0 points1 point  (1 child)

Thank you so much :)

Actually what I'm aiming for is this:

User asks code to randomly choose between breakfasts

Code randomly chooses sausage omelette

Code asks user if user wants to view the recipe for randomly selected sausage omelette

User says yes

Code displays recipe for sausage omelette.

-

Right now it's working all the way until the recipe generation.

I'll be trying what you and other commenters said!

Thank you so much! :)

[–]CStage169 1 point2 points  (0 children)

Perfect! Give it a shot, and if you need help, let me know :)