タグ

ブックマーク / ama-ch.hatenablog.com (1)

  • 今日のPython - はてブロ@ama_ch

    breakとcontinue p.84 >>> for item in range(10): ... if item == 5: continue ... if item == 8: break ... print item, ... 0 1 2 3 4 6 7 while文 whileの条件はbool型(真or偽)で判定される。 p.86 >>> n = 0 >>> while n < 10: ... print n, ... n += 1 ... 0 1 2 3 4 5 6 7 8 9 九九の表を出力 よくやるよね。 >>> a = 1 >>> b = 1 >>> while a < 10: ... while b < 10: ... print a * b, ... b += 1 ... print "" ... a += 1 ... 1 2 3 4 5 6 7 8 9 あれ、できな

    今日のPython - はてブロ@ama_ch
    U1and0
    U1and0 2016/06/14
    Pythonではdo〜while文がないので、while文(無限ループ)とbreakを組み合わせて書く。
  • 1