+ 1

Can anyone explain!

Words=["hello","world","what's","up"] for word in words: Print(word[-1:5])

9th May 2020, 2:46 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
3 Risposte
+ 2
You are printing the part of each word that goes from the last letter (-1) to the 5th letter, but non-inclusive. The last letter of "what's" is also the 5th letter, so since it's non-inclusive, nothing is printed for that one.
9th May 2020, 2:53 PM
HonFu
HonFu - avatar
+ 1
Not satisfying
9th May 2020, 2:56 PM
《A$# ☆ $ING#》
《A$# ☆ $ING#》 - avatar
0
It may not satisfy you, but it's exactly what's going on in your code anyway. What was your aim, what sort of output did you expect instead? Maybe we can find another way to achieve it.
9th May 2020, 4:08 PM
HonFu
HonFu - avatar