title: Creating a dictionary from txt file Python
body: <p>I'm trying to take a text file with a list in it take the input values and order them in an appropriate output format however I'm having difficulty trying to create a loop and create this dictionary. </p>
  
  <p>I have created a blank dictionary however I'm not sure I'm supposed to create a dictionary like in order to get the output: </p>
  
  <pre><code>foodweb =
  {
    “Bird”: [
      Prawn,
      Mussels,
      Crab,
      Limpets,
      Whelk
    ],
    “Crab”: [
      Mussels,
      Limpets
    ],
    “Fish”: [
      Prawn
    ],
    “Limpets”: [
      Seaweed
    ],
    “Lobster”: [
      Crab,
      Mussels,
      Limpets,
      Whelk
    ],
    “Mussels”: [
      Phytoplankton,
      Zooplankton
    ],
    “Prawn”: [
      Zooplankton
    ],
    “Whelk”: [
      Limpets,
      Mussels
    ],
    “Zooplankton”: [
      Phytoplankton
    ]
  }
  </code></pre>
  
  <p>How can I write a loop to make this more simple?!?</p>
  
  <pre><code>file_content = open('AquaticFoodWeb.txt' , 'r')
  aquaticfoodweb ={}
  for line in file_content:
      myList=line.rstrip('\n').split(" eats ")
  </code></pre>
  
  <p>This is the list from the txt file</p>
  
  <pre><code>Bird eats Prawn
  Bird eats Mussels
  Bird eats Crab
  Bird eats Limpets
  Bird eats Whelk
  Crab eats Mussels
  Crab eats Limpets
  Fish eats Prawn
  Limpets eats Seaweed
  Lobster eats Crab
  Lobster eats Mussels
  Lobster eats Limpets
  Lobster eats Whelk
  Mussels eats Phytoplankton
  Mussels eats Zooplankton
  Prawn eats Zooplankton
  Whelk eats Limpets
  Whelk eats Mussels
  Zooplankton eats Phytoplankton
  </code></pre>
  
  <p>This is the desired output format I'm striving for:</p>
  
  <pre><code>Predators and Prey:
  Bird eats Prawn, Mussels, Crab, Limpets and Whelk
  Crab eats Mussels and Limpets
  Fish eats Prawn
  Limpets eats Seaweed
  Lobster eats Crab, Mussels, Limpets and Whelk
  Mussels eats Phytoplankton and Zooplankton
  Prawn eats Zooplankton
  Whelk eats Limpets and Mussels
  Zooplankton eats Phytoplankton
  </code></pre>