I'm trying to solve a problem where I wish to select multiple words beginning with 's', but have both the lowercase and uppercase words be shown in the output.
To try and achieve my desired result, I used an if-else statement in a for-loop but it only selected the first value I chose. For example, if I wrote 'S' first, it selected the uppercase and ignored the lowercase.
st = 'Sally sells shakes from Shake Shack every Saturday.'
for i in st.split():
if i[0] == 's' and 'S':
print(i)
I expected the output to be: sells shakes Sally Shake Shack Saturday
But the actual output was: sells shakes
Aucun commentaire:
Enregistrer un commentaire