首页 > 解决方案 > 为什么这种格式无效?

问题描述

for skill in skills if skill != "engineering":
   ...

技能是一个列表,我想在遍历列表时进行检查。

标签: python

解决方案


这是正确的版本

for skill in skills: # <- with :
   if skill != "engineering": # <- with new indention
       ...  # <- with new indention

推荐阅读