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


Groups > comp.lang.python > #96522

convert element in a list to float

X-Received by 10.50.67.107 with SMTP id m11mr9363444igt.8.1442174123497; Sun, 13 Sep 2015 12:55:23 -0700 (PDT)
X-Received by 10.140.43.182 with SMTP id e51mr50373qga.7.1442174123428; Sun, 13 Sep 2015 12:55:23 -0700 (PDT)
Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!peer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!kq10no4071798igb.0!news-out.google.com!l36ni385qgd.1!nntp.google.com!v79no890985qge.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail
Newsgroups comp.lang.python
Date Sun, 13 Sep 2015 12:55:13 -0700 (PDT)
Complaints-To groups-abuse@google.com
Injection-Info glegroupsg2000goo.googlegroups.com; posting-host=216.172.93.64; posting-account=ow5fuAkAAAA7L41YpssmITSJFyElSoXi
NNTP-Posting-Host 216.172.93.64
User-Agent G2/1.0
MIME-Version 1.0
Message-ID <417abfa4-e7c7-4573-83ed-50b8a5aca2b2@googlegroups.com> (permalink)
Subject convert element in a list to float
From forums_mp@hotmail.com
Injection-Date Sun, 13 Sep 2015 19:55:23 +0000
Content-Type text/plain; charset=ISO-8859-1
X-Received-Bytes 1463
X-Received-Body-CRC 2522859361
Xref csiph.com comp.lang.python:96522

Show key headers only | 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