TypeError: list indices must be integers, not float

前端 未结 4 610
感情败类
感情败类 2021-02-05 02:47

I have a python 3.x program that is producing an error:

def main():
    names = [\'Ava Fischer\', \'Bob White\', \'Chris Rich\', \'Danielle Porter\',
                    


        
4条回答
  •  旧时难觅i
    2021-02-05 03:37

    I had this problem when using ANN and PyBrain on function testOnData().

    So, I solved this problem putting "//" instead "/" inside the index on backprop.py source code.

    I changed:

    print(('Max error:', 
        max(ponderatedErrors), 
        'Median error:',
         sorted(ponderatedErrors)[len(errors) / 2])) # <-- Error area 
    

    To:

    print(('Max error:', 
        max(ponderatedErrors), 
        'Median error:',
         sorted(ponderatedErrors)[len(errors) // 2])) # <-- SOLVED. Truncated
    

    I hope it will help you.

提交回复
热议问题