یک جمله داده شده است، تعداد کلماتی که اولین و آخرین حرف آنها یکسان است را برگردانید.
نمونه ورودی و خروجی
count_same_ends("Pop! goes the balloon") ➞ 1
count_same_ends("And the crowd goes wild!") ➞ 0
count_same_ends("No I am not in a gang.") ➞ 1
نکات:
- کلمات تکحرفی شمارش نمیشوند (مانند “I” و “A” در مثال سوم).
- حروف بزرگ و کوچک معادل در نظر گرفته میشوند (مثلاً “P” و “p” برابرند).
count_same_ends("Pop! goes the balloon") ➞ 1
count_same_ends("And the crowd goes wild!") ➞ 0
count_same_ends("No I am not in a gang.") ➞ 1
count_same_ends('My mom is not a nun.') ➞ 2
count_same_ends('A fine morning') ➞ 0
count_same_ends('Taste the difference') ➞ 0
نظرات