title: Need help in printing dictionary & adding user prompt to obtain nested list values [Python]
body: <p>I am currently working on a function named generate_qns_from_list(). This function should take in a list. This function should convert the list into a list of dictionaries. Each dictionary will have two keys - &quot;qns&quot; and &quot;ans&quot;. The value for the &quot;qns&quot; key will be a string of the integers taken from a list in the input list. And the integers are separated with the characters &quot;+&quot;, &quot;-&quot;, &quot;x&quot;, &quot;/&quot; from the input list as shown below:</p>
  <pre><code>input_list = [[&quot;+&quot;,1,3,3], [&quot;-&quot;,2,5,-1],
  [&quot;x&quot;,3,2],[&quot;/&quot;,12,3,2],[&quot;x&quot;,0,23],[&quot;+&quot;,1,2,3,4]]
  generate_qns_from_list(input_list)
  
  # output
  [{&quot;qns&quot;: &quot;1 + 3 + 3&quot;, &quot;ans&quot;: 7},
  {&quot;qns&quot;: &quot;2 - 5 - -1&quot;, &quot;ans&quot;: -2},
  {&quot;qns&quot;: &quot;3 x 2&quot;, &quot;ans&quot;: 6},
  {&quot;qns&quot;: &quot;12 / 3 / 2&quot;, &quot;ans&quot;: 2},
  {&quot;qns&quot;: &quot;0 x 23&quot;, &quot;ans&quot;: 0},
  {&quot;qns&quot;: &quot;1 + 2 + 3 + 4&quot;, &quot;ans&quot;: 10}]
  </code></pre>
  <p>This is my code:</p>
  <pre><code>import math
  
  def generate_qns_from_list(lst):
      qns_list = []
      for sub_list in lst:
          operator, *numbers =  sub_list
          d = {}
          qns = str(operator).join(map(str, sub_list))
          d[&quot;qns&quot;] = f&quot;{qns}&quot;
          ans = math.prod(sub_list)
          d[&quot;ans&quot;] = ans
          qns_list.append(d)
      
      return qns_list
  </code></pre>
  <p>I keep getting this output:</p>
  <pre><code>[{'qns': '++1+3+3', 'ans': '+++++++++'},
   {'qns': '--2-5--1', 'ans': ''},
   {'qns': 'xx3x2', 'ans': 'xxxxxx'},
   {'qns': '//12/3/2',
    'ans': '////////////////////////////////////////////////////////////////////////'},
   {'qns': 'xx0x23', 'ans': ''},
   {'qns': '++1+2+3+4', 'ans': '++++++++++++++++++++++++'}]
  </code></pre>