title: What would be the best way to run a loop within a print statement that is extracting data from a list in Python?
body: <p>I'm trying to extract data from a csv file, this is the shortened version of one of the columns of data</p>
  
  <pre><code>import csv
  
  with open('Movie2.csv', 'r') as csv_file:
      csv_reader = csv.reader(csv_file)
      counter = 0
      for line in csv_reader:
          counter +=1
          print('Movie m%d' % counter, "= new Movie();", '\n',
                   'm'+str(counter)+'.Genres.Add(db.Genres.FirstOrDefault(x =&gt; x.GenreName == "' % line[2]+'"));', '\n')
  </code></pre>
  
  <p>"line[2]" is usually multiple genres and may look like this "Horror, Thriller, Drama". My goal is for this particular code the end result should looke like:</p>
  
  <pre><code>Movie m1 = new Movie();
  m1.Genres.Add (db.Genres.FirstOrDefault(x =&gt; x.GenreName == "Horror"));
  m1.Genres.Add (db.Genres.FirstOrDefault(x =&gt; x.GenreName == "Thriller"));
  m1.Genres.Add (db.Genres.FirstOrDefault(x =&gt; x.GenreName == "Drama"));
  </code></pre>