{ "metadata": { "name": "", "signature": "sha256:b2a6ed5ea7e5abacdcacafe8c425541b11d5a49dbd227fb9b4570858a4e820cc" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# For Loop\n", "\n", "- **Author:** [Chris Albon](http://www.chrisalbon.com/), [@ChrisAlbon](https://twitter.com/chrisalbon)\n", "- **Date:** -\n", "- **Repo:** [Python 3 code snippets for data science](https://github.com/chrisalbon/code_py)\n", "- **Note:**\n", "\n", "The for loop iterates over each item in a sequences." ] }, { "cell_type": "code", "collapsed": false, "input": [ "# One at a time, assign each value of the sequence to i and,\n", "for i in [432, 342, 928, 920]:\n", " # multiply i by 10 and store the product in a new variable, x create a new variable, x,\n", " x = i * 10\n", " # print the value of x\n", " print(x)\n", "# after the entire sequence has been processes,\n", "else:\n", " # print this\n", " print('All done!')" ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", "text": [ "4320\n", "3420\n", "9280\n", "9200\n", "All done!\n" ] } ], "prompt_number": 2 } ], "metadata": {} } ] }