0
Output question
What's the output? s='sololearn' print(s[:][:1]) Solution: s Shouldn't the solution be "o" as "o" is index 1? Thanks for any help:).
5 Answers
+ 8
tristach605 I believe the answer should be 1 as well.
Unless,
you change [:1] to just [1]
+ 5
Diego It is edited.
+ 5
list[:1] is not the same as list[1]. list[:1] is equivalent to list[0:1] and means: return a slice of the list starting with index 0, ending with (but not including) index 1. That's why the letter at index 0 (s) is the only letter that is printed
+ 4
âĄPrometheus ⥠Either the post was edited or you posted this in the wrong place.
0
Hey Prometheus and Diego.
Pardon me as I make a mistake (and have since endited the post).
so? any ideas on why this is "s" and not "o"?
thanks for any help anyone could procide:).