{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "world hello\n" ] } ], "source": [ "# Write a Python class to reverse a string word by word.\n", "# Input \"hello world\"\n", "# Output \"world hello\"\n", "\n", "class py_solution:\n", " def reverse_words(self, s):\n", " return ' '.join(reversed(s.split()))\n", "\n", "\n", "print(py_solution().reverse_words('hello world'))\n" ] } ], "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 }