0
how to find the second question in strings???
2 ответов
+ 2
https://code.sololearn.com/cIi14FFULifV
import re
text = "- Hello! How are you?\n- I'm fine. And you?" #original text
print(text)
strings = text.split("?")
strings = [s + "?" for s in strings if s!=""]
questions = []
for str in strings:
for sentence in re.split('\. |! |\.|!|- |-|\n', str):
if(sentence[-1:] == '?'):
questions.append(sentence)
print("\nSecond question is: ")
print (questions[1]) # print second question
+ 1
<<"\""