社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
私信  •  关注

Landar

Landar 最近创建的主题
Landar 最近回复了
6 年前
回复了 Landar 创建的主题 » 跳过python中的索引
li = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
condition3_reached = False
condition10_reached = False
for i in li:
    print(i)
    if conditition3_reached and not condition10_reached and i != 10:
        continue
    if condition3_reached and i == 10:
        condition10_reached = True
    if i == 3 and (#along with other condition):
        condition3_reached = True
        print(i)
    else:
        do_some_new_thing_for_10_onwards()

这是一个简单的实现你想要的东西的方法。我担心它不可扩展