suite_de_lettres~20171216-165747.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. # Copyright (C) 2016 Constant, Algolit
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, either version 3 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details: <http://www.gnu.org/licenses/>.
  12. # Reduction of letters
  13. # From string to list & back
  14. # A string: a list of characters, unchangeable, but treatable
  15. # See: https://www.tutorialspoint.com/python3/python_strings.htm
  16. # Write sentence as string
  17. sentence = "Je vois La Vie en rose... Tu vois Le Ciel en vert!"
  18. # Print sentence
  19. print("phrase originale:", sentence)
  20. new_letter = []
  21. words = sentence.split()
  22. # for each word
  23. for word in words:
  24. # iterate over letters of word
  25. for letter in word:
  26. new_letter.append(letter)
  27. #print(new_letter)
  28. print("phrase sans espaces:", "".join(new_letter))
  29. #for letter in new_letter:
  30. # new_letter = letter.sort(" ")
  31. new_letter.sort()
  32. print(new_letter)
  33. print("suite de lettres", "".join(new_letter))