推荐一个学习语言的网站:http://www.codecademy.com 有教程,可以边学边写,蛮不错的. for循环: 1.for loops allow us to iterate through all of the elements in a list from the left-most (or zeroth element) to the right-most element. A sample loop would be structured as following: 使用fo…
For in 循环主要适用于遍历一个对象中的所有元素.我们可以使用它遍历列表,元组和字典等等. 其主要的流程如下:(图片来源于: https://www.yiibai.com/python/python_for_loop.html) 使用For遍历一个列表: peoples = ['Ralf', 'Clark', 'Leon', 'Terry'] for people in peoples: print(people) ''' 输出: Ralf Clark Leon Terry ''' 使用Fo…
3.3.3 break 和 continue语句 break:跳出整个循环 continue:跳出当前循环继续后面的循环 例: x=int(input("please input the 'x':")) y=0 for y in range(0,100): if(x==y): print("the number is :",x) break else: print("The number was not found") x=0 for i in…