Why do method 1 and method 2 not print the same output?
>>> names = ["Apple", "Samsung", ]
# Method 1/Print the first item in names
>>> print(names[:1])
['Apple']
# Method 2/Print the first item in names
>>> print(names[0])
Apple
Why do method 1 and method 2 not print the same output?
>>> names = ["Apple", "Samsung", ]
# Method 1/Print the first item in names
>>> print(names[:1])
['Apple']
# Method 2/Print the first item in names
>>> print(names[0])
Apple
Slicing syntax (Method 1) always produces a new list, even if the new list has only one item.
Indexing (Method 2) produces the item at that position in the iterable.