A slice is inclusive of the starting index and exclusive of the ending index.
def slice4(s):
c = s[0:2]
return c
| Function Call | Return Value | |||
|---|---|---|---|---|
| slice4('Car') | → | |||
| slice4('Truck') | → | |||
| slice4('556843') | → | |||
| slice4('Elephant') | → | |||
| slice4('Roses') | → | |||
Experiment with this code on Gitpod.io