文字列を区切り文字で大文字にする際に、私は動作に遭遇しましたが、わかりません。ループ中に文字列sが元に戻った理由を誰かが説明できますか?ありがとう。ループ内の文字列のPythonの動作
s = 'these-three_words'
seperators = ('-','_')
for sep in seperators:
s = sep.join([i.capitalize() for i in s.split(sep)])
print s
print s
stdout:
These-Three_words
These-three_Words
These-three_Words