{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-5\n" ] } ], "source": [ "# Write a Python program to sum all the items in a list\n", "# Example sum_list([1,2,-8])\n", "# Return -5\n", "\n", "def sum_list(items):\n", " sum_numbers = 0\n", " for x in items:\n", " sum_numbers += x\n", " return sum_numbers\n", "print(sum_list([1,2,-8]))" ] } ], "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.1" } }, "nbformat": 4, "nbformat_minor": 2 }