-1
我必须在Python中实现下面的伪代码。Python for循环单线程连接2个字符串
dict = {}
list1 = [1,2,3,4,5,6]
list2 = [2,4,5,7,8]
dict['msg'] = "List 2 items not in list 1 : "
for x in list 2:
if x in list1:
dict['msg'] += x
<write in log : dict['msg']>
如果我使用味精的价值列表
dict['msg'] = ["List 2 items not in list 1 : "]
我可以追加在单排的值作为
[dict['msg'].append(x) for x in L2 if x not in L1]
但随后的输出页面上的结果将作为
msg : [
"List 2 items not in list 1 :",
7,
8
]
我想要结果si斜线为
msg : List 2 items not in list 1 : 7,8
我该如何做到这一点?
因为我需要为其余代码的字典。 – pratibha
已更新的回答。 –