On Saturday, November 7, 2015 at 9:40:49 PM UTC-5, MRAB wrote:
> On 2015-11-08 02:11, phamton...@gmail.com wrote:
> > 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
> >
> You're slicing the wrong end off 'long'.
> 
> You have '-81.4]'. You want '-81.4'. You should be doing long[ : -1].

Ah! Thank you so much!
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to