2015-12-26から1日間の記事一覧
コード # coding=utf-8 def chunked(iterable, n): return [iterable[x:x + n] for x in range(0, len(iterable), n)] if __name__ == '__main__': arr = range(10) print(chunked(arr, 4)) # => [[0, 1, 2, 3], [4, 5, 6, 7], [8, 9]] 参考 python2でリスト…
変更2020-06-09: python2.xの raw_input が python3.x で input に変更になっているので修正 コード hoge.py def yes_no_input(): while True: choice = input("Please respond with 'yes' or 'no' [y/N]: ").lower() if choice in ['y', 'ye', 'yes']: retu…