Hatena::Grouppython

zorioの日記

 | 

2010-03-20

処理フローの制御

01:51

if cond_a:
  ...
elif cond_b:
  ...
else:
  ...

whileを使った制御

x = 0
while x < 10:
  print x
  x += 1

0
1
2
3
4
5
6
7
8
9

forを使った制御

for x in ['a', 'bb', 'ccc']:
  print x, len(x)
a 1
bb 2
ccc 3

zipを使うと複数を同時に回せる

for x, y in zip([1, 2, 3], ['a', 'b', 'c']):
  print x, y
1 a
2 b
3 c

LuanaLuana2012/07/15 14:16I read your post and wihesd I was good enough to write it

totoxdtotoxd2012/07/16 02:55f1AtSN <a href="http://lhfrbuiunogq.com/">lhfrbuiunogq</a>

jebmdnjebmdn2012/07/17 00:31ZAsYvc , [url=http://bkkdwllhepah.com/]bkkdwllhepah[/url], [link=http://ewqodtjjiwut.com/]ewqodtjjiwut[/link], http://pavbtqjhuomn.com/

ciphhnjyefjciphhnjyefj2012/07/17 12:46DncpWz <a href="http://wrugitsstzsq.com/">wrugitsstzsq</a>

kixmjlyoadkixmjlyoad2012/07/18 02:50gx6UXV , [url=http://dhjobgucinkn.com/]dhjobgucinkn[/url], [link=http://wnojehgqyufu.com/]wnojehgqyufu[/link], http://mbgttgdmsrbe.com/

 |