title: How to put cards on Anki Deck using Python
body: <p>I have an Anki Deck here, is there a way that I could programmatically insert a card on my current sample deck right here? See the image provided</p>
  <p><a href="https://i.stack.imgur.com/LoCjQ.png" rel="nofollow noreferrer">Anki Deck image sample</a></p>
  <p>Is there a way to do that with python? Since it is known that Anki is written in Python I have the feeling that is could be possible.</p>
  <p>Also I have found this python package that you can actually create a deck and a card but I was thinking how can I insert the card object or Note as they would call it on the documentation... How can it be inserted to a current deck in Anki? Here is the code</p>
  <pre><code>import genanki
  
  my_model = genanki.Model(1607392319,'Simple Model',
    fields=[
      {'name': 'Question'},
      {'name': 'Answer'},
    ],
    templates=[
      {
        'name': 'Card 1',
        'qfmt': '{{Question}}',
        'afmt': '{{FrontSide}}&lt;hr id=&quot;answer&quot;&gt;{{Answer}}',
      },
    ])
  
  
  
  
  my_note = genanki.Note(
    model=my_model,
    fields=['Capital of Argentina', 'Buenos Aires'])
  
  
  
  my_deck = genanki.Deck(
    2059400110,
    'Country Capitals')
  
  my_deck.add_note(my_note)
  
  genanki.Package(my_deck).write_to_file('output.apkg')
  </code></pre>
  <p>Link to the github -&gt; <a href="https://github.com/kerrickstaley/genanki" rel="nofollow noreferrer">genanki</a></p>