Guest User

Untitled

a guest
Dec 12th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. y = []
  2. while True:
  3. user_input = input('type text')
  4. divide_string = user_input.split()
  5.  
  6. for x in divide_string:
  7. y.append(x)
  8. if user_input == '':
  9. break
  10. else:
  11. continue
  12.  
  13. print(" ".join(sorted(y)))
  14.  
  15. import string
  16. ...
  17. punctuation_map = {ord(char): None for char in string.punctuation}
  18. while True:
  19. user_input = input('type text')
  20. clean_data = user_input.translate(punctuation_map)
  21. divide_string = clean_data.split()
  22. ...
  23.  
  24. import re
  25.  
  26. # исходные данные
  27. user_input = 'type text. hello'
  28. # с помощью регулярных выражений извлечем только слова длиной больше 3 символов
  29. worlds = re.findall('w{3,}', user_input)
  30. # сортируем и выводим
  31. print(sorted(worlds))
  32.  
  33. ['hello', 'text', 'type']
Add Comment
Please, Sign In to add comment