正解: apple, 解答: aple → 0 点 (長さが異なる)
正解: orange, 解答: olange → 1 点 (長さは同じだが 1 文字だけ異なる)
正解: grape, 解答: glepe → 0 点 (長さは同じだが 2 文字異なる)
正解: lemon, 解答: lemon → 2 点 (完全一致)
4
apple aple
orange olange
grape glepe
lemon lemon
下記、採点合計は正しいのですが、途中がおかしいと指摘されました。
N=int(input()) sum=0 check=0 for i in range(N): a,b= input().split() if a==b: sum=sum+2 #print(i,a,b,sum1,"sum1") elif not len(a)==len(b): sum=sum #print(i,a,b,len(a),len(b),sum2,"sum2") elif len(a)==len(b): for i in range(len(a)): if a[i]==b[i]: check=check #print(i,a,b,len(a),len(b),sum) elif not a[i]==b[i]: check=check+1 #print(i,a,b,a[i],b[i],check) if check==2: sum=sum #print(i,a,b,len(a),len(b),check,sum3,"sum3") ckeck=0 elif check==1: sum=sum+1 #print(i,a,b,len(a),len(b),sum4,"sum4") check=0 print(sum)
で、しつもんはなんでしょうか
回答1件
あなたの回答
tips
プレビュー