-2

Use for, .split(), and if to create a Statement that will print out words that start with 's':

st = 'Print only the words that start with s in this sentence'

eisa.exe
  • 78
  • 9
xdkyaka
  • 1
  • 1

2 Answers2

0

Try this instead

st = 'Print only the words that start with s in this sentence'
Answer = [word for word in st.split() if word[0] == 's']
print(Answer)
Ran A
  • 746
  • 3
  • 7
  • 19
Akash Saha
  • 11
  • 1
-1

Split the list into Strings with .split(). Use " " as a separator because you want spaces to separate the words.

st = "Print only the words that start with s in this sentence"
words = []
for word in st.split(" "):
    if word.startswith("s"):
        words.append(word)

print(words)
eisa.exe
  • 78
  • 9