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 = {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']
- y = []
- while True:
- user_input = input('type text: ')
- divide_string = user_input.split()
- for x in divide_string:
- y.append(x.replace('.', ''))
- if user_input == '':
- break
- else:
- continue
- print(" ".join(sorted(y)))
- from string import punctuation
- def y(lj=lambda w: ''.join(s for s in w if s not in punctuation)):
- user_input = input('type text')
- while user_input:
- yield from map(lj, user_input.split())
- user_input = input('type text')
- print(*sorted(y()))
Add Comment
Please, Sign In to add comment