-1

My list looks like this:

food_order = ['Spicy Chicken Sandwich', 'Chick-fil-A Waffle Potato Fries', 'Chic-fil-A Lemonade', 'Chocolate Chunk Cookie']

and I would like for it to look like:

Spicy Chicken Sandwich

Chick-fil-A Waffle PotatoFries

Chic-fil-A Lemonade

Chocolate Chunk Cookie
  • 2
    That's not a dictionary (it's a `list`), and you're basically asking how to use a `for` loop and `print` (or maybe `join` and `print`). If you don't know how to do this, you have so many fundamental things to learn it's not practical for you to learn them piecemeal with questions here. Run through a tutorial in its entirety, or talk to your teacher. – ShadowRanger Apr 12 '20 at 23:47
  • I meant list, my bad. I have been working all day and am getting my terms mixed up – Emily Johnson Apr 12 '20 at 23:48

3 Answers3

1

As simple as:

for x in food_order:
  print(x)

Or if you want to print a new line after every item:

for x in food_order:
  print(x+"\n")
hiew1
  • 1,394
  • 2
  • 15
  • 23
1

You can join a list with new lines and print it:

food_order = ['Spicy Chicken Sandwich', 'Chick-fil-A Waffle Potato Fries', 'Chic-fil-A Lemonade', 'Chocolate Chunk Cookie']

print('\n\n'.join(food_order))

This will stick two new line characters between each of your list items and make a new string.

Result:

Spicy Chicken Sandwich

Chick-fil-A Waffle Potato Fries

Chic-fil-A Lemonade

Chocolate Chunk Cookie
Mark
  • 90,562
  • 7
  • 108
  • 148
-1

Code:

food_order = ['Spicy Chicken Sandwich', 'Chick-fil-A Waffle Potato Fries',
              'Chic-fil-A Lemonade', 'Chocolate Chunk Cookie']
for food in food_order:
    print(food)
    print('\n')

Output:

Spicy Chicken Sandwich

Chick-fil-A Waffle Potato Fries

Chic-fil-A Lemonade

Chocolate Chunk Cookie
AMC
  • 2,642
  • 7
  • 13
  • 35