-
-
Save cibofdevs/bc08540e5ef357425bb01ee638965bbd to your computer and use it in GitHub Desktop.
| # 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"
Write your code here.
new_sentence = sentence.split(" ")
same_letter_count = 0
for i in new_sentence:
if i[len(i)-1] == i[0]:
same_letter_count += 1
print(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 = 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)
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)
sentence = "students flock to the arb for a variety of outdoor activities such as jogging and picnicking"
new_sentence = sentence.split(" ")
same_letter_words = []
for word in new_sentence:
if word[0] == word[-1]:
same_letter_words.append(word)
same_letter_count = len(same_letter_words)
print(same_letter_count)