Python单层for循环
2018-01-26 10:55
260 查看
# -*- coding: UTF-8 -*- I0 = [1,2,3]; I1 = [4,5,6]; print 'connect I0 and I1', I0 + I1 num0 = len(I0) num1 = len(I1) print 'length of I0: ', num0 v1 = range(0,num0) print 'all elements of v1: ', v1 I3 = range(0,num0) for i in v1: I3[i] = I0[i] + I1[i] print 'the', i, 'th element in I3: ', I3[i] print('Good bye')
运行结果:
connect I0 and I1 [1, 2, 3, 4, 5, 6] length of I0: 3 all elements of v1: [0, 1, 2] the 0 th element in I3: 5 the 1 th element in I3: 7 the 2 th element in I3: 9 Good bye
相关文章推荐
- 4.Python - for循环语句
- python for循环语句
- python新手必碰到的问题---encode与decode,中文乱码,for 循环 in判断中文
- Python for 循环语句
- python开发之for循环操作实例详解
- python for循环输入一个矩阵的实例
- Python学习(8)--for循环
- python之For/While循环遍历文件【基础篇】
- Java--for 循环之单层循环 执行顺序
- python开发_python中for循环操作
- 3. Python - while 和 for 循环
- 关于Python中的for循环控制语句
- python jpype 调用Hanlp,使用列表解析.toString.encode("utf-8") 会出现乱码,需用使用for 循环
- python——用lambda函数替换for循环
- 【python】理解循环:for,while
- Python for 循环的一个坑
- python 用lambda函数替换for循环的方法
- python语法 3.1 双重for循环
- Python菜鸟--for 循环语句
- python的for、while循环和if条件语句