playbook/antigravity-awesome-skills/skills/loki-mode/benchmarks/results/2026-01-05-00-49-17/humaneval-solutions/91.py

20 lines
601 B
Python

def is_bored(S):
"""
You'll be given a string of words, and your task is to count the number
of boredoms. A boredom is a sentence that starts with the word "I".
Sentences are delimited by '.', '?' or '!'.
For example:
>>> is_bored("Hello world")
0
>>> is_bored("The sky is blue. The sun is shining. I love this weather")
1
"""
import re
sentences = re.split(r'[.?!]', S)
count = 0
for sentence in sentences:
stripped = sentence.lstrip()
if stripped.startswith('I ') or stripped == 'I':
count += 1
return count