python - Converting one string to a int in a list -


I want to convert an int to an integer in a list. Example:

  x = ['1', '24', 'M', 'Technician', '85711']   

First Element x [0] to switch to an integer:

  x = [1, '24', 'M', 'technician', '85711'] < / code>   

Simply assign an index to the list:

  & Gt; & Gt; & Gt; X = ['1', '24', 'M', 'Technician', '85711']> gt; & Gt; & Gt; X [0] = int (x [0])> gt; & Gt; & Gt; X [1, '24', 'M', 'Technician', '85711'] & gt; & Gt; & Gt;   

This solution list keeps the object the same:

  & gt; & Gt; & Gt; X = ['1', '24', 'M', 'Technician', '85711']> gt; & Gt; & Gt; ID (x) 35174000 & gt; & Gt; & Gt; x [0] = int (x [0])> gt; & Gt; & Gt; ID (x) 35174000 & gt; & Gt; & Gt;    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -