What does g(xs[:-2])
mean?
def f(xs):
def g(ys):
return ys[::-1]
return [x-2+(2*7/4) for x in g(xs[:-2])]
What does g(xs[:-2])
mean?
def f(xs):
def g(ys):
return ys[::-1]
return [x-2+(2*7/4) for x in g(xs[:-2])]
Here's how it works, it passes xs
variable (a string/list) and slices it to remove the last two elements/characters (-2 means to slice from the end of string/list) to function g()