Python formating all values in list of lists
<p>I am so sorry that I asking so silly question
but could you help me please format list of lists ("%.2f") for example:</p>

<pre><code>a=[[1.343465432, 7.423334343], [6.967997797, 4.5522577]]
</code></pre>

<p>I used:</p>

<pre><code>  for x in a:
     a = ["%.2f" % i for i in x]
     print (a)
</code></pre>

<p>OUT:</p>

<pre><code>['1.34', '7.42']
['6.97', '4.55']
</code></pre>

<p>But I would like to get my list of lists
OUT:</p>

<pre><code>[['1.34', '7.42'] ,['6.97', '4.55']]
</code></pre>

<p>In a simpler way, you may achieve the same using list comprehension as:</p>

<pre><code>&gt;&gt;&gt; a=[[1.343465432, 7.423334343], [6.967997797, 4.5522577]]
&gt;&gt;&gt; [["%.2f" % i for i in l] for l in a]
[['1.34', '7.42'], ['6.97', '4.55']]
</code></pre>

<p>Infact even your code is fine. Instead of print, you need to just <code>append</code> the values you are printing to a list</p>

python list format