Guest User

Untitled

a guest
Mar 13th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 1,
  6. "metadata": {},
  7. "outputs": [
  8. {
  9. "name": "stdout",
  10. "output_type": "stream",
  11. "text": [
  12. "Once: 1\n",
  13. "Twice: 2\n",
  14. "Once: 2\n",
  15. "Twice: 4\n"
  16. ]
  17. }
  18. ],
  19. "source": [
  20. "\"\"\"\n",
  21. " In the above example, we create two dictionaries, once and twice, that have the same keys.\n",
  22. " Because we know that they have the same keys, \n",
  23. " we can loop through one dictionary and print values from both once and twice.\n",
  24. "\"\"\"\n",
  25. "\n",
  26. "once = {'a': 1, 'b': 2}\n",
  27. "twice = {'a': 2, 'b': 4}\n",
  28. "for key in once:\n",
  29. " print (\"Once: %s\" % once[key])\n",
  30. " print (\"Twice: %s\" % twice[key])"
  31. ]
  32. },
  33. {
  34. "cell_type": "code",
  35. "execution_count": null,
  36. "metadata": {
  37. "collapsed": true
  38. },
  39. "outputs": [],
  40. "source": []
  41. }
  42. ],
  43. "metadata": {
  44. "kernelspec": {
  45. "display_name": "Python 3",
  46. "language": "python",
  47. "name": "python3"
  48. },
  49. "language_info": {
  50. "codemirror_mode": {
  51. "name": "ipython",
  52. "version": 3
  53. },
  54. "file_extension": ".py",
  55. "mimetype": "text/x-python",
  56. "name": "python",
  57. "nbconvert_exporter": "python",
  58. "pygments_lexer": "ipython3",
  59. "version": "3.6.3"
  60. }
  61. },
  62. "nbformat": 4,
  63. "nbformat_minor": 2
  64. }
Add Comment
Please, Sign In to add comment