python的循环语句
来源:互联网 发布:分布式数据库解决方案 编辑:程序博客网 时间:2024/06/04 18:41
l = ['Bart', 'Lisa', 'Adam']n=2while n>=0: print("helllo,",l[n])
n=n-1
要注意的是python中需要循环的时候要在执行的语句前缩进,不然会报错:
IndentationError: expected an indented block
其它的实现方法:range(3)产生一个从0开始的包含3个元素的序列:即:0,1,2
l = ['Bart', 'Lisa', 'Adam']for i in range(3): print(l[i])
当然直接让i成为l列表中的一个元素,从而直接提取也可:
l = ['Bart', 'Lisa', 'Adam']for i in l: print("hello,",i)
0 0
- python的循环语句
- Python的循环语句
- python的循环语句
- python里面的循环语句
- python的条件和循环语句
- python list循环语句的使用方法
- Python学习 for循环语句的使用
- 详解Python中的循环语句的用法
- Python中的循环语句
- Python中的循环语句
- python 循环语句
- Python循环语句
- Python for 循环语句
- Python While循环语句
- python循环语句
- python中的循环语句
- Python循环语句
- Python循环语句
- poj1176 Party Lamps dfs优化+规律枚举
- Java反射机制浅析图+应用实例
- JS组件系列——表格组件神器:bootstrap table
- onCreate(Bundle savedInstanceState)
- 暑期dp46道(45)--HDOJ 1257 最少拦截系统 最长递增子序列
- python的循环语句
- hive修改默认元数据存储数据库derby改为mysql
- 【JZOJ 4714】 公约数
- 从boost到Adaboost再到GBRT-GBDT-MART
- DOM加载
- 文件的QFileDialog打开 保存
- Ubuntu下gcc版本的切换
- 你为什么一定要使用 Google ?
- Python 类的多继承