-4
如果我有一个列表A
如下:A = [word, 5]
和其他列表B
其中B = [4]
,我怎么能乘只有数字,并拿出那是一个列表如下:new_list = [word, a * b]
?乘以两个列表,当其他列表中包含的话,以及
如果我有一个列表A
如下:A = [word, 5]
和其他列表B
其中B = [4]
,我怎么能乘只有数字,并拿出那是一个列表如下:new_list = [word, a * b]
?乘以两个列表,当其他列表中包含的话,以及
事情是这样的,如果你有多个号码的清单也许
for i in a:
if isinstance(i, int): #Checking if it is an int or not
for j in b:
if isinstance(j, int):
c.append(i*j)
else:
if j not in c:
c.append(j)
else:
c.append(i)
会发生什么?你能给我们一些更多的样本输入/输出吗? – abagshaw
你期望从A = ['word',5,'text']','B = ['string',4]''? –
本质上我有一个列表,其中每个索引本身是一个包含一个单词和一个数字的列表。然后我有一个只包含数字的列表,我想将它们自己的数字相乘。 –