Many ways to skin this cat. Understanding slice notation is definitely a starting point.
name = "Youtube"
sub = name[3:6] # "tub"
Even more basic is accessing individual elements by index:
x = name[3] # "t"
y = name[5] # "b"
Also helpful, particular to get edge elements, is unpacking:
x, _*, y = sub # will get t and b respectively
This does: of the iterable sub
, assign the first element to x
, the last one to y
, and what ever is in between to an anonymous list _
. No need to know the length of sub
in advance and works with iterators where you wont be able to use slices or negative indexing.