Write the regular expression that will match a string if there are no spaces right before the last ending punctuation ?. Use the character class \S in your expression.
txt1 = "Can read a spray chart and a balance sheet. 1 part Executive, 1 part entrepreneur, 2 parts geek and 3 parts baseball coach. Too many parts?"
txt2 = "Can read a spray chart and a balance sheet. 1 part Executive, 1 part entrepreneur, 2 parts geek and 3 parts baseball coach. Too many parts ?"
pattern = "yourregularexpressionhere"
bool(re.search(pattern, txt1)) ➞ True
bool(re.search(pattern, txt2)) ➞ False? in RegEx, the pattern must include \?.import re from the code.