def encounter(stest,ytest):
red = []
Stests = []
Ytests = []
for line in stest.splitlines():
if not line.isspace() and line != "":
Stests.append(line)
for line in ytest.splitlines():
if not line.isspace() and line != "":
Ytests.append(line)
smax = len(Stests)
ymax = len(Ytests)
for step in range(max(smax,ymax)):
try:
sworld = Stests[step].split
except:
sworld.append("")
try:
yworld = Ytests[step].split
except:
yworld.append("")
if sworld != yworld:
red.append((step),sworld[step],yworld[step])
print(red)
encounter("red demons dragon","star dust dragon")
split() 这个后面的括号没了
还有最后面red.append方法没这样写的吧
先把代码格式贴好吧,这样看都是缩进错误,而且有很多循环条件语句不清楚你的嵌套