It's dangerous to go alone


#1

Just curious as to why this is:

my_dict = {
... "fish": ['c', 'a', 'r', 'p']}
print my_dict["fish"][0:1]
['c'] #this is the result of using [0:1] for slicing
print my_dict["fish"][0]
c #this is the result of using [0]

Why does python print ['c'] for [0:1] and not just c

`


#2

If you copy a part of a list then the result is also going to be a list, not a character


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.