title: How can lists in a list be overwritten by new lists in a new list in Python?
body: <p>If someone knows how to phrase the question to make it clearer, feel free to edit it!</p>
  
  <p>I have a list like this:</p>
  
  <pre><code>a = [["Adolf", "10"], ["Hermann", "20"], ["Heinrich", "30"]]
  </code></pre>
  
  <p>and I have an 'update' list like this:</p>
  
  <pre><code>b = [["Rudolf", "40"], ["Adolf", "50"]]
  </code></pre>
  
  <p>I want to be able to add new entries and overwrite identical entries in list <code>a</code> using list <code>b</code>:</p>
  
  <pre><code>c = magic(a, b)
  </code></pre>
  
  <p>The result should be as follows:</p>
  
  <pre><code>&gt;&gt;&gt; print(c)
  [["Adolf", "50"], ["Hermann", "20"], ["Heinrich", "30"], ["Rudolf", "40"]]
  </code></pre>
  
  <p>Is there a function like magic in existence? If not, how could it be written?</p>
  
  <hr>
  
  <p>EDIT: Just to be clear, I am aware of the dictionary approach. For my purposes, I need to have duplicate entries, so dictionaries are not appropriate -- that's why I asked about lists. Before it is mentioned, there'll be protections for these special duplicate entries. For example, let's say "Heinrich" is one of these special types of entry that can have duplicates:</p>
  
  <pre><code>a = [['Adolf', '10'], ['Hermann', '20'], ['Heinrich', '30'], ['Heinrich', '15']]
  </code></pre>
  
  <p>Now, let's say I have the update list as the following:</p>
  
  <pre><code>b = [['Rudolf', '40'], ['Adolf', '50']]
  </code></pre>
  
  <p>Updating list <code>a</code> with list <code>b</code> should result in the following list:</p>
  
  <pre><code>&gt;&gt;&gt; print(c)
  [['Adolf', '50'], ['Hermann', '20'], ['Heinrich', '30'], ['Heinrich', '15'], ['Rudolf', '40']]
  </code></pre>
  
  <p>As you can see, there are intended <em>duplicate</em> entries. This is why a dictionary cannot be used directly.</p>