{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "dog. lazy the over jumps fox brown quick The\n", "Exercises. Python\n" ] } ], "source": [ "# 'The quick brown fox jumps over the lazy dog.'\n", "# input : \"The quick brown fox jumps over the lazy dog.\"\n", "# output : \"dog. lazy the over jumps fox brown quick The \"\n", "\n", "def reverse_string_words(text):\n", " for line in text.split('\\n'):\n", " return(' '.join(line.split()[::-1]))\n", " \n", "print(reverse_string_words(\"The quick brown fox jumps over the lazy dog.\"))\n", "print(reverse_string_words(\"Python Exercises.\"))" ] } ], "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 }