title: How to prepare a list containing a mix of integers, float and strings?
body: <p>Say I have a data</p>
  
  <pre><code>data = 'A|B|2|D|0.3|5|kg|1.69|m'
  </code></pre>
  
  <p>I want to convert this into list using split('|'), but I get the list where all the values are converted to strings. I didn't see any similar problem on SE.</p>
  
  <p><strong>How can I get something like:</strong></p>
  
  <pre><code>data_list = ['A','B',2,'D',0.3,5,'kg',1.69,'m']
  </code></pre>
  
  <p>where the type of the data are as they are (either int, str or float).</p>
  
  <p>I don't want a very lengthy function but <strong>a shortest and simplest way to do it, is lambda possible (I am trying but no success so far)?</strong>, else something else is fine too. </p>
  
  <p>any ideas. </p>
  
  <p>Post edit:</p>
  
  <p>I tried using lambda in following way:</p>
  
  <pre><code>da_list02 = map(lambda x: float(x) if type(float(x)) is float else str(x), da_list)
  </code></pre>
  
  <p>But, I am getting <code>ValueError</code>.
      ValueError: could not convert string to float: A</p>
  
  <p><strong>Shouldn't the <code>else</code> part of the <code>lambda function</code> cover it? What's wrong with the <code>lambda function</code>?</strong></p>