You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defstem(name:str) ->str:
idx=min(name.find('-'), name.find('^'), key=lambdax: xifx>=0elselen(name))
returnname[:idx]
# The result should be always ABC, but this one fails# In the min() calling both find() returns -1 that is going to be substituted with 3 by the lamba# So that we should get min(3,3), instead we get -1print(stem('ABC'))
print(stem('ABC-DE'))
print(stem('ABC-DE^FGH'))
print(stem('ABC-DE^FGH^JKL'))
print(stem('ABC^FGH^JKL'))
print(stem('ABC^FGH'))
According to the docs the key function is applied to each element. So that on the first case we should arrive to min(3,3). I was expecting 3, instead I get -1.
The same result comes out if we pass a collection (a tuple in this case):