title: How to replace strings in a list using tuples of strings and their replacements?
body: <p>I have a list of player ranks attributed to players.  In addition to this, I have a list of tuples of ranks...</p>
  
  <pre><code>rank_database = [("Unprocessed Rank", "Processed Rank"), ("Unprocessed Rank 2", "Processed Rank 2")]
  </code></pre>
  
  <p>What I would like to do is, for every item in the player ranks list, process them through the rank database --- like find and replace.</p>
  
  <p>So, before replacement:</p>
  
  <pre><code>player_ranks = ["Unprocessed Rank", "Unprocessed Rank 2"]
  </code></pre>
  
  <p>After replacement:</p>
  
  <pre><code>player_ranks = ["Processed Rank", "Processed Rank 2"]
  </code></pre>
  
  <p>Essentially, I would like to use <code>rank_database</code> to perform a find and replace operation on the <code>player_ranks</code> list.</p>
  
  <h1>Proposed Solution</h1>
  
  <p>My idea was to try to use the tuples with the <a href="https://docs.python.org/3/library/stdtypes.html#str.replace" rel="nofollow"><code>str.replace</code></a> method as follows... </p>
  
  <pre><code>player_ranks = ["Unprocessed Rank", "Unprocessed Rank 2"]
  rank_database = [("Unprocessed Rank", "Processed Rank"), ("Unprocessed Rank 2", "Processed Rank 2")]
  
  for x in player_ranks:
      for y in rank_database:
          print("Changed "+x+" to")
          if x == y[0]:
              player_ranks[x].replace(rank_database[y]) #Line 5
              print (x)
              break
          else:
              continue
  print("Finished!")
  </code></pre>
  
  <p>When I execute the code, since <code>("Unprocessed Rank", "Processed Rank")</code> is a tuple found at <code>rank_database[i]</code>, I'm hoping this will sort of "inject" the tuple as the replacement strings in the <code>str.replace</code> method. </p>
  
  <p>So, when executing the code, Line 5 should look like...</p>
  
  <pre><code>rank.replace(("Unprocessed Rank", "Processed Rank"))
  </code></pre>
  
  <p>Would this be a possible solution, or is this not possible, and would other solutions be more appropriate?  This is for a personal project, so I would prefer to get my own solution working.</p>