Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- y = []
- while True:
- user_input = input('type text')
- divide_string = user_input.split()
- for x in divide_string:
- y.append(x)
- if user_input == '':
- break
- else:
- continue
- print(" ".join(sorted(y)))
- import string
- ...
- punctuation_map = dict((ord(char), None) for char in string.punctuation)
- while True:
- user_input = input('type text')
- clean_data = user_input.translate(punctuation_map)
- divide_string = clean_data.split()
- ...
- import re
- # исходные данные
- user_input = 'type text. hello'
- # с помощью регулярных выражений извлечем только слова длиной больше 3 символов
- worlds = re.findall('w{3,}', user_input)
- # сортируем и выводим
- print(sorted(worlds))
- ['hello', 'text', 'type']
Add Comment
Please, Sign In to add comment