Last active
January 6, 2024 02:39
-
-
Save cibofdevs/bc08540e5ef357425bb01ee638965bbd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The variable sentence stores a string. | |
| # Write code to determine how many words in sentence start and end with the same letter, including one-letter words. | |
| # Store the result in the variable same_letter_count. | |
| sentence = "students flock to the arb for a variety of outdoor activities such as jogging and picnicking" | |
| # Write your code here. | |
| same_letter_count = sum(w[0] == w[-1] for w in sentence.split()) | |
| print(same_letter_count) |
sentence = "students flock to the arb for a variety of outdoor activities such as jogging and picnicking"
word = sentence.split()
same_letter_count = 0
Write your code here.
for i in word:
if (i[0] == i[-1]):
same_letter_count +=1
print(same_letter_count)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sentence = "students flock to the arb for a variety of outdoor activities such as jogging and picnicking"
Write your code here.
same_letter_count = 0
sentence_split = sentence.split(" ")
print(sentence_split)
for i in sentence_split:
if i[0]==i[-1]:
same_letter_count = same_letter_count + 1
print(same_letter_count)