abecedaire.py 618 B

1234567891011121314151617181920212223
  1. #!/usr/bin/python
  2. # this is a shebang: https://en.wikipedia.org/wiki/Shebang_%28Unix%29
  3. '''
  4. This script takes a sentence you write in the terminal, and gives it back in alphabetical order
  5. Check out other options for list comprehension: https://docs.python.org/3/tutorial/datastructures.html
  6. Made for OLA #5, Paris, 15-17 décembre 2017
  7. '''
  8. # Run script in loop:
  9. while True:
  10. # Ask to write a sentence
  11. sentence = input("Ecrivez votre phrase: ").lower().strip('\., \?')
  12. # Split sentence into words
  13. words = sentence.split()
  14. #print(words)
  15. # sort wordlist
  16. words.sort()
  17. print(" ".join(words).capitalize(), '.')