Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98414
| X-Received | by 10.129.83.85 with SMTP id h82mr260521ywb.0.1446948676148; Sat, 07 Nov 2015 18:11:16 -0800 (PST) |
|---|---|
| X-Received | by 10.50.108.107 with SMTP id hj11mr32141igb.1.1446948676121; Sat, 07 Nov 2015 18:11:16 -0800 (PST) |
| Path | csiph.com!au2pb.net!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!m48no5973162qgd.0!news-out.google.com!z4ni2462ign.0!nntp.google.com!i2no1048704igv.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
| Newsgroups | comp.lang.python |
| Date | Sat, 7 Nov 2015 18:11:15 -0800 (PST) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=166.164.37.186; posting-account=C4V26AoAAAA7DPYhYjPL-VTM6X5uY8KM |
| NNTP-Posting-Host | 166.164.37.186 |
| User-Agent | G2/1.0 |
| MIME-Version | 1.0 |
| Message-ID | <2ced12ff-ae0c-4e86-ac38-357558251e51@googlegroups.com> (permalink) |
| Subject | Converting a string into a float that includes the negative |
| From | phamtony33@gmail.com |
| Injection-Date | Sun, 08 Nov 2015 02:11:16 +0000 |
| Content-Type | text/plain; charset=UTF-8 |
| Content-Transfer-Encoding | quoted-printable |
| X-Received-Bytes | 1855 |
| X-Received-Body-CRC | 739010427 |
| Xref | csiph.com comp.lang.python:98414 |
Show key headers only | View raw
I am having issue with converting the string into a float because there is a negative, so only end up with "ValueError: invalid literal for float(): 81.4]"
def contains_words(word,msg):
if word in msg:
return true
else:
return false
def get_tweet(tweet_line):
part_list = tweet_line.split('\t')
tweet = part_list[3]
return tweet
def get_longitude(tweet_line):
part_list = tweet_line.split('\t')
gps = part_list[0]
gps_list = gps.split(', ')
long = gps_list[1]
long1 = long[1:]
longitude = float(long1)
return longitude
a = get_longitude("[41.3, -81.4]\t6\t2011-08-28 19:02:28\tyay. little league world series!")
print a
the answer should be
get_longitude("[41.3, -81.4]\t6\t2011-08-28 19:02:28\tyay. little league world series!") → -81.4
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Converting a string into a float that includes the negative phamtony33@gmail.com - 2015-11-07 18:11 -0800
Re: Converting a string into a float that includes the negative MRAB <python@mrabarnett.plus.com> - 2015-11-08 02:40 +0000
Re: Converting a string into a float that includes the negative phamtony33@gmail.com - 2015-11-07 18:44 -0800
Re: Converting a string into a float that includes the negative Pete Dowdell <contact@stridebird.com> - 2015-11-08 09:39 +0700
csiph-web