Ответ:
Python 3.7
import re
import string
def firstWord(s:str) -> str:
cs = re.sub(rf'[{string.punctuation}]|\n', '', s)
cs = re.sub(r' +', ' ', cs)
return cs.split(' ')[0]
print('first word: ' + firstWord(input('Enter some string: ')))
Объяснение:
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Ответ:
Python 3.7
import re
import string
def firstWord(s:str) -> str:
cs = re.sub(rf'[{string.punctuation}]|\n', '', s)
cs = re.sub(r' +', ' ', cs)
return cs.split(' ')[0]
print('first word: ' + firstWord(input('Enter some string: ')))
Объяснение: