下記コードにて、いくつか挙動の理解ができないため
ご教授頂けると幸いです。
def long_repeat(line): if not line: return 0 return max(len(line) - len(line.lstrip(line[0])), long_repeat(line.lstrip(line[0]))) long_repeat("122fffff")
返り値:5
不明点
① return 0 がなぜ必要なのか?
②なぜlong_repeat(line.lstrip(line[0])) の返り値が5になるか?
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/05/03 04:04
2018/05/03 04:08
2018/05/03 04:41