#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright (C) 2016 Constant, Algolit # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details: . # Reduction of letters # From string to list & back # A string: a list of characters, unchangeable, but treatable # See: https://www.tutorialspoint.com/python3/python_strings.htm # Write sentence as string sentence = "Je vois La Vie en rose... Tu vois Le Ciel en vert!" # Print sentence print("phrase originale:", sentence) new_letter = [] words = sentence.split() # for each word for word in words: # iterate over letters of word for letter in word: new_letter.append(letter) #print(new_letter) print("phrase sans espaces:", "".join(new_letter)) #for letter in new_letter: # new_letter = letter.sort(" ") new_letter.sort() print(new_letter) print("suite de lettres", "".join(new_letter))