Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": 1,
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Once: 1\n",
- "Twice: 2\n",
- "Once: 2\n",
- "Twice: 4\n"
- ]
- }
- ],
- "source": [
- "\"\"\"\n",
- " In the above example, we create two dictionaries, once and twice, that have the same keys.\n",
- " Because we know that they have the same keys, \n",
- " we can loop through one dictionary and print values from both once and twice.\n",
- "\"\"\"\n",
- "\n",
- "once = {'a': 1, 'b': 2}\n",
- "twice = {'a': 2, 'b': 4}\n",
- "for key in once:\n",
- " print (\"Once: %s\" % once[key])\n",
- " print (\"Twice: %s\" % twice[key])"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.6.3"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Add Comment
Please, Sign In to add comment