#!/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) # Convert sentence in one word (remove spaces) #one_word = sentence.strip(" ") #print("sans les espaces:", one_word) # define new word as list new_word = [] # Convert sentence in list of words words = sentence.split() #print(words) # For each word in word list for word in words: # remove capital letters (string operation) #word = word.lower() # Clean punctuation (string operation) #word = word.strip(" ;''?:,()!.\").”-") # add word to new word list new_word.append(word) #new_letter = [] #letter = words.split() #print(letter) # Write words as one, without spaces print("phrase sans espaces:", "".join(new_word))