title: Generating a list of ternary numbers of length l with digit by digit inquiry possibility in python
body: <p>I want to generate a list of ternary numbers of length l and save into a dictionary. Then I want the ability to compare these numbers digit by digit and do modifications too.</p>
  
  <p>For example if the length <code>l=2</code>, the dictionary should contain numbers: <code>00,01,02,10,11,12,20,21,22</code>.</p>
  
  <p>Then I want to do operations like comparing the <code>ith</code> digit of the <code>jth</code> entry in the dictionary with the <code>kth</code> digit of the <code>lth</code> entry. Like in the above list, comparing "0" of the entry "20" with "1" of the entry "21"</p>
  
  <p>Also I should be able to sum up the digits of the <code>ith</code> entry of the dictionary. Like sum of the entry "11" = 2.</p>
  
  <p>Please suggest me a way to do the above things. I am new to coding in python.</p>
  
  <p>Here is my try but this doesn't give me 2 digit numbers. So a suggestion for how to go to tens place from ones place and so on, would be appreciated:</p>
  
  <pre><code>dict = {}
  n = 0
  dict[0] = 00
  while (n &lt; 9):
     dict[n+1]= (dict[n] +1) % 3
     if dict[n+1] = 2
     n = n +1
  
  print (dict)   `
  </code></pre>