Search Result

Collapse
2 results in 0.0041 seconds.
Keywords
Members
Tags
invalid literal
  •  

  • TMS
    started a topic ValueError: invalid literal for float():

    ValueError: invalid literal for float():

    I'm working on a linear regression program and when I try to convert the input file data to a float (it reads in as a string), I get this error. Perhaps someone can help me? I'm using Windows XP, and IDLE. (also the console screen).

    Code:
    #! /usr/bin/env python
    import sys
    import os
    from numpy import * 
    numLst = [] #an empty list
    if len(sys.argv) == 2:
    	infile = open(sys.argv[1], 'r')
    elif len(sys.argv)
    ...
    See more | Go to post

  • aine_canby@yahoo.com
    Guest started a topic Avoiding "invalid literal for int()" exception

    Avoiding "invalid literal for int()" exception

    >>v = raw_input("Ente r: ")
    Enter: kjjkj
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    ValueError: invalid literal for int() with base 10: 'kjjkj'

    In my program I need to be able to enter char strings or int strings on
    the command line. Then I use an if-elif structure to establish which is
    which. For example -

    if uniList[0].lower()...
    See more | Go to post
Working...