我的函数在true的“ if”输出上返回None
我尝试使用return语句,但是它没有用,可能我做的不正确
class Check_alpha:
def __init__(self, word):self.word = word
def word_end(self):
P,M,N = self.word, self.word[-1], self.word[-2:]
ending_alpha # a function below
def split():
if ' ' in self.word:
self.word = self.word.split(' ')
for ch in range(len(self.word)):
#here i am trying to apply ending alpha to each split word
print(ending_alpha(self.word[ch], self.word[ch][-1], self.word[ch][-2:]))
else:
print(ending_alpha(P, M, N))
return split()
ending_alpha = lambda p,m,n:f'{p}u' if m == 'c' else f"{p,replace(p[-2:], 'ji')}" if n == 'ge' else f'{p}'
change = Check_alpha('age sac')
print(change.word_end())
预期输出应为 阿吉萨库 相反,我越来越 阿吉 萨库 没有