Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #96522

convert element in a list to float

Newsgroups comp.lang.python
Date 2015-09-13 12:55 -0700
Message-ID <417abfa4-e7c7-4573-83ed-50b8a5aca2b2@googlegroups.com> (permalink)
Subject convert element in a list to float
From forums_mp@hotmail.com

Show all headers | View raw


For starters, I googled and saw a plethora of writings on how to convert an entire list from string to float.   My interest is on select elements in the list.  The output from the print statement: print scenarioList 
  
is as follows

[ '3000000', '"N"', '11400000', '"E"' ]

I need to convert the first and third element to float.  
  lat = ( float ) scenarioList [ 0 ]
  lon = ( float ) scenarioList [ 2 ]

fails (invalid syntax).  How can I achieve my objective. 

Thanks in advance

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

convert element in a list to float forums_mp@hotmail.com - 2015-09-13 12:55 -0700
  Re: convert element in a list to float Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-09-13 21:07 +0100
  Re: convert element in a list to float Laura Creighton <lac@openend.se> - 2015-09-13 23:02 +0200
    Re: convert element in a list to float Denis McMahon <denismfmcmahon@gmail.com> - 2015-09-13 23:43 +0000
  Re: convert element in a list to float Steven D'Aprano <steve@pearwood.info> - 2015-09-14 11:09 +1000

csiph-web