Python3,怎么=for循环,方便下次运算?

e = content.split('\n')
ax = input()
for i in e:
    if ax in i:
        print(i)

a ="上面的结果"

e = content.split('\n')

ax = input()

result = '\n'.join(t for t in e if ax in t)

print(result)

???没看懂

Python3,怎么=for循环,方便下次运算?
对于这个题意,不知道我理解的对不对
我感觉如果是方便运算可以写个方法函数在该使用时调用该函数就行了。

如有帮助,还请帮忙点下采纳!感谢!

给你找了一篇非常好的博客,你可以看看是否有帮助,链接:python3 for循环踩过的坑