对不起,这已被无疑地问过,但我似乎无法找到它。我想从python列表中返回一个列表,但是当我尝试这样做时,它似乎将列表作为字符串返回,因此将始终访问第一个if语句。返回列表里面的列表 - Python
def multpoly(entryList):
x = entryList.index(0)
if type(x) is list:
print("list")
if type(x) is str:
combined_str = ""
for x in entryList:
combined_str += x
return combined_str
print(multpoly(["1", "2", "3"]))
你问为什么字符串“1,2,3”是一个字符串?那将是因为它是一个字符串。 – TigerhawkT3
避免使用列表作为变量名称;它也是Pÿthon中内置函数的名称。 –
请提供预期的输出。 – trincot