循环 ,其意思是一直从复的做某件事情。
Python的格式:
Python的循环有两种,一种是for...in循环,依次把list或tuple中的每个元素迭代出来,看例子:
name=['zhang','li','wang']
for name in name:
print(name)
zhang
li
wang
[Finished in 1.1s]
sum=0
for x in range(101):
sum=sum+x
print(sum)
5050
格式while
sum =0
n =99
whilen >0:
sum = sum + n
n = n -2
print(sum)