【发布时间】:2020-10-16 05:39:59
【问题描述】:
我正在尝试编写一个简单的程序,它只运行一个字符串列表,并将每个字符串与包含一些相同单词的较短字符串列表进行比较。然后我想打印出长列表中不在短列表中的所有单词。我认为我有正确的逻辑,但我似乎无法让打印工作。这是我所拥有的:
oneList = ['egg', 'duck', 'cow']
twoList = ['egg', 'giraffe', 'cow', 'poo', 'speaker']
for twoString in twoList:
for oneString in oneList:
if (twoList[twoTicker] = oneList[oneTicker]):
#do nothing
else:
#do nothing
#if it reaches end of list and isnt there, print word.
【问题讨论】: