Để chính xác, chuỗi trên có 4 từ bắt đầu bằng uppercase: This, Delhi, City, India.
Dùng 2 hàm string. Giả sử từ cách nhau bởi space đơn, split() cho list từ. Để kiểm tra ký tự đầu mỗi từ là uppercase, dùng isupper().
Code liệt kê từ bắt đầu bằng chữ hoa:
s1 = "This is not true that Delhi is the hottest or coldest City in India"
for word in s1.split():
if word[0].isupper():
print(word)
Output:
This Delhi City India