文字列のpythonでの部分文字列を見つけるが、私は答えを見つけるように見えることはできませんどこでも、私が検索しcharachersが異なるにされた別の文字列から部分文字列を返すにはどうすればよいこれは初心者の質問かもしれません
注文?
私は以下のコードをチェックすると、正解が出ているようですが、それを真正または偽にして印刷しようとしています。また、提出すると、「間違っています。 (UdaciousUdacitee、Udacity)。あなたの投稿は、4つのテストケースのうち3つを通過しました。「....私は混乱しています.3時間ほど私の脳を包み込んでいます。 。
はTest case 1: False
Test case 2: True
Test case 3: True
Test case 4: True
より正確にありがとう:
def fix_machine(debris, product):
if debris.find(product):
return product
else:
print("Give me something that's not useless next time.")
print "Test case 1: ", fix_machine('UdaciousUdacitee', 'Udacity') == "Give me something that's not useless next time."
print "Test case 2: ", fix_machine('buy me dat Unicorn', 'Udacity') == 'Udacity'
print "Test case 3: ", fix_machine('AEIOU and sometimes y... c', 'Udacity') == 'Udacity'
print "Test case 4: ", fix_machine('wsx0-=mttrhix', 't-shirt') == 't-shirt'
ここまでお試しください。スタックオーバーフローは、他の人にあなたのコードを書くように依頼するのに適していません。 – smarx