diff --git a/ejercicio1.ipynb b/ejercicio1.ipynb new file mode 100644 index 0000000000000000000000000000000000000000..c76d39436a64605f52c2d53c3b5b39203a5fc7ca --- /dev/null +++ b/ejercicio1.ipynb @@ -0,0 +1,77 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Nombre: Juan Manuel Moreno Pérez\n", + "# Usuario: morenoj" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "• Escriba un programa en python que acepte una lista de palabras separadas por guiones, e\n", + "imprima de vuelta las mismas palabras, sin repetición y nuevamente separadas por guiones,\n", + "después de ordenarlas alfabéticamente.\n", + "\n", + "Ejemplo de entrada: naranja-avión-melodÃa-tupla-avión\n", + "\n", + "Salida esperada: avión-melodÃa-naranja-tupla" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "naranja-avión-melodÃa-tupla-avión\n", + "avión-melodÃa-naranja-tupla\n" + ] + } + ], + "source": [ + "txt=input()\n", + "txt=txt.split('-')\n", + "txt=sorted(txt)\n", + "prev=''\n", + "ret=''\n", + "for i in range(len(txt)):\n", + " if txt[i]==prev:\n", + " continue\n", + " else:\n", + " ret+=txt[i]\n", + " if i<len(txt)-1:\n", + " ret+='-'\n", + " prev=txt[i]\n", + "print(ret)" + ] + } + ], + "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.8.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +}