The first character in a string is at index 0.
def slice3(s):
length = len(s)
mid = int(length / 2)
c = s[mid]
return c
| Function Call | Return Value | |||
|---|---|---|---|---|
| slice3('Car') | → | |||
| slice3('Truck') | → | |||
| slice3('556843') | → | |||
| slice3('Elephant') | → | |||
| slice3('Roses') | → | |||
Experiment with this code on Gitpod.io