私は問題に苦しんでいます。「1D10M1I10M1D」のような文字列があり、整数の開始 = 10
文字列の整数を使用して、文字列内の各 I または D の位置を報告する方法がわかりません
私は次のようなことをしました:
match = re.findall(r'(\d+)(\w)', a)
print match
文字列と整数の個別の値を取得する
次のように出力したいと思います:
1 D 10 #(it is the first D so its position (10) == value pos (10)
1 I 21 #(I counting from pos 10 + 1D + 10M = 21)
1 D 32 #(D counting from pos 10 + 1D + 10M +1I + 10M = 32)
これで私を助けることができますか?