0
先生は、別の文字列文字を使用して文字列の出現回数をカウントする関数を作成するよう依頼しました。だから、例えば:文字列内の複数の文字を個別にカウントする
>>>problem3("all is quiet on the western front", "tqe")
>>>["t=4", "q=1", "e=4"]
しかし、私はそれが何を得ることができます。
>>>problem3("all is quiet on the western front", "tqe")
>>>[4, 1, 4]
は、これは私のコードです:私は、「[この形式でトンをそれを得るにはどうすればよい
def problem3(myString, charString):
return [myString.count(x) for x in (charString)]
= 4 "、" q = 1 "、" e = 4 "
あなたは最高です、ありがとうございました。 – thatoneguy