• #### 科普

SCIENCE

#### 英语

ENGLISH

#### 科技

TECHNOLOGY

MOVIE

FOOD

#### 励志

INSPIRATIONS

#### 社会

SOCIETY

TRAVEL

#### 动物

ANIMALS

KIDS

#### 卡通

CARTOON

#### 计算机

COMPUTER

#### 心理

PSYCHOLOGY

#### 教育

EDUCATION

#### 手工

HANDCRAFTS

#### 趣闻

MYSTERIES

CAREER

GEEKS

#### 时尚

FASHION

• 精品课
• 公开课
• 欢迎下载我们在各应用市场备受好评的APP

点击下载Android最新版本

点击下载iOS最新版本

扫码下载译学馆APP

#### Python中的For循环

For Loop - Python Basics

The for loop within python is the second major loop

within most coding languages as well.

Um…in my opinion,

this is, most dynamic, most useful loop that you’ll come across.

Um…So here is what we’ve got here. We’ve got this array here,

That has 1, 2, 3, 4 different things within the array.

We just got the pieces of strings here.

And so what we’re gonna do is
for 循环的结构就是
for…the way this works is…the for loop is,
for 每一个元素 in 元素集合
for everything in something,

basically, do this,

so what we are going to say here is,

for, and here you kind of define the variable.

Doesn’t matter what you call it, it just defines it.

Um…so we’re gonna say, for item in

Um…And in here, our variable that we would like to consider is x,

same thing as well, end with a colon, ‘enter’,

Um…so for item in x,

you can also say, for word in x, whatever,

then you come down here, and then you use ‘word’,

and then it’ll apply each time to a different part of this array.

So we’ll say, for every word that’s within our array x,

we want to print out ‘python is’,

and as we learn before, comma will add a space automatically for us,

and ‘word’, so for word in x,

we want to print out ‘python is’, word,

and it’s gonna say, it’s going to add this to the end.
OK 保存
So let’s go ahead save it,

And as you can see, ‘python is nifty’,
python 强大有力 技惊四座
‘python is powerful’, ‘python is awesome’,
python是最好的语言
‘python is the best language’.

So there you have it.

B11101001

[B]Azrael