It is also a question for beginners of Python, about empty tandem and so on.

" I understand that the empty string
[] is an empty string
check the args [0] [: 0] in the code below
use type (args [0] [: 0]) will be marked as < class" list" >
compare it with [] ("d"]) successfully executed
executed print (adder1 ("god", "damn", "it")) reported
does not know the difference.

def adder1(*args):
    if type(args[0])==type(0):
        sum = 0
    else:
        sum = args[0][:0]
    for arg in args:
        sum = sum + arg
    return sum

print(adder1("god","damn","it"))
print(adder1(["a","b"],["c","d"]))
Mar.10,2021

if you analyze the calculation process in detail, you will find the difference. The python variable parameter * para will compose the parameters into tuple storage. Therefore,

adder1("god","damn","it") -sharp args = ("god","damn","it")
adder1(["a","b"],["c","d"]) -sharp args = (["a","b"],["c","d"])

anyone with a solid foundation of python knows

-sharp args = ("god","damn","it")
args[0][:0] = ''
-sharp args = (["a","b"],["c","d"])
args[0][:0] = []

is obviously two different types, one is ', an empty string, and the other is an empty list of [] . In python, both the string and list can be computed directly
, so there is the above result.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf53b7-31f56.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf53b7-31f56.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?