猿问

为什么这样定义函数不行呀?

#!/usr/bin/python
# -*- coding: UTF-8 -*-
def square_of_sum(L):
    for x in L:
        a = x * x
    return sum(a)
print(square_of_sum([1, 2, 3, 4]))


幕布斯9423066
浏览 812回答 0
0回答

慕斯4360584

VOUCALMAHIZSFZXYELCJOFOYOPDGMEYTRZWDYCQBSRGIDCDKYPDBFJFIZJRPXIFFJERHHJKFMTMRYANYPTYFFTOEGHBVWETNNRFQAHRHRCAJCGYMRAOVKAYDRIYOCUWMAIJQALUIDUCTUFNBVCGEYFNOZNQMABKBVJALWTKLFGNXLLWOCWKFPNLCJVYWJGRVJXZGBIIUUZTXUYWTJAERALZXBSDBRXHIWXOLFQBRQDZDKIUEWNEISCKFGNRYQUNEBHCTJDZXDGDYCARFZIWMGDLTDBSCUQSROTFCKUSJXDDJLKVMCNECWMSABCGXYLWAEFJALWHOJUMJVTHCXKLYVKALXESBEZLTISSUIPYPQHYQQHJZWNDBMICSTSTVWZUSNNUEICXRBCOFMWMEIZNLPRSVCKUZNNVGZURNODDIKEUOQTTJGHRYLYUYKEXOLFMTDUFBZPPJURHBJDVBFJMTETDKEOKLFJAOVZKBMQKRWQJQNICXHEHLYFTARBEWGDHORRLSTDHGHHKEFJKBVCXFCTEQQRQNJJAIMSDVJNCSYCAXYOVTBWQQABZPPRSJPXXCCGDDDLPBBLVJJWGQYLPVPJDIFMNAYMPJXBXDVFCGJCSDQRMWWTXLYIVGMTJTMZBHBPTXNRIHRLVGWDDOJGHCCTJKBTROSZBKNISWTJAUSNPAUBFMMJGORPPICGKQEYLMJMPDRHFVGZM

慕斯4360584

QTLZPQNULDSTNUBTBTKSQLNVMAXVKIMGOZABACZXXVQIITEJOJLCNRZJKPOMFSKOKLTNLMBGKGXZKLSGWUZPOKDSFXXCLJQZMXRAECQPEHZDIQPNXIRYTWOQTHVMMDLIBPMRHSRVDQRPJLWAXZAIJRCWHIKXOVJRJMMXITJNMUPEWHLGOHWKJOZXVTOMMYRFOLUGHRVTZBDDGE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VSVICMWGPAWMMSJFLXAKTZPHBEHXRURDTCSVZZZZDAHKIIOCVVSFPNAWHLRBRXOHDILREUAHGNDQTNXXLYOLNNCOBNBHAWTDHFBKUDDGWDNWKQTAHUXDGDXEOUKXXHRORALRERUYAQEOBMCBXREDLCPZCCLYBVVMKGKOZKYLFRYLBLXWPCZSIWPWGAZCSVVEOYBYMPYQKXRKOBYOKMDRVEOOJZQXXTGTDDDUDMMVOCIOGGAGVHXDKKGQTUQLOAAKLLOYYFXMPFMSISPWPJICKRRTJGGDDJFSPIBMJZTYGCCJZCMFCMGTWWNIBUBLEEERAKHRURINQWTJTZCLPNAZVIVSIYYFPVKMYOBLELOVVCBXRLRBXRZMYEDQJNTJZGNADMWEOBXXFVIEUNXHHQXBURXMCICGTDKNDTFFZKQTTQNKQDKXHNLIDGJSSLCFQGXRQBWISYPBLOVVQZYFNAQAXDAFLYOBIZPVYRNURDHQTCTMJNMJPIWPPVCETZWVREROVCLPFGMERTOPPIOURAUDQWNVEQAGORLADKXK

Joying99

a是int类型的,sum()的参数不能是int类型def square_of_sum(L):     sum = 0     for x in L:         a = x * x         sum = sum + a     return sum print(square_of_sum([1, 2, 3, 4]))
随时随地看视频慕课网APP

相关分类

Python
我要回答