Python: TypeError: 'NoneType' object is not subscriptable

前端 未结 1 701
再見小時候
再見小時候 2021-01-15 01:43
#Uses python3

import sys

def max_dot_product(a,b,n):


    a = a.sort(reverse=True)
    b = b.sort(reverse=True)
    res = 0

    for i in range(n):
        res +=         


        
相关标签:
1条回答
  • 2021-01-15 02:28

    sort sorts a list in place and (implicitly) returns None. Drop the assignment of the return value and you should be OK:

    a.sort(reverse=True)
    b.sort(reverse=True)
    
    0 讨论(0)
提交回复
热议问题