Currently I'm studying on for loops and I've been given an assessment to get a better grab of it which was asking for me to printing only the words starting with 's' in the following string
st = 'Print only the words that start with s in this sentence'
and I wrote that simple codeline to get the job done
for word in st.split():
if word[0] == 's' or 'S':
print (word)
which resulted in following output
Print
only
the
words
that
start
with
s
in
this
sentence
The point couldn't grasp on is if I use and
operator between 's' and 'S' or don't even use and operator between them (by demolishing 'S' of course.) instead of 'or' operator. I get the desired result which is:
start
s
sentence
Any ideas why is this happening and how I failed to understand the difference between them would be very much appreciated