Skip to content

Instantly share code, notes, and snippets.

@cibofdevs
Last active January 6, 2024 02:39
Show Gist options
  • Save cibofdevs/bc08540e5ef357425bb01ee638965bbd to your computer and use it in GitHub Desktop.
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)
@chiemezie1
Copy link

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)

@BanureaPanji
Copy link

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