uhyohyoohooho
uhyouhaahaaha
さて機械的にこの文字列が等しいかどうか判定するために、Python初心者の私が考えたことは
---
「うーん、2つの文字を"listA"と"listB"のリストにしてfor文で繰り返し、iのときのa[i]とb[i]が等しいければいけるかなぁ」
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
listA = list(input()) | |
listB = list(input()) | |
n = len(listA) | |
for i in range (n): | |
if listA[i] == listB[i]: | |
print........ |
・・・とprintのところで悩みました。
1文字ずつ何を出力したいんだろう・・・?
あれ、えーと全部正しければいいからprintする必要もないし
iを入れて違うところでelseでfor抜けて"違う文字列でした"を表示すれば、いやいやfor抜けたら正しい文字列でも表示されるんじゃくぁwせdrftgyふじこlp・・・
~10分後~
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if listA == listB: | |
print("同じ文字列です") |
超シンプルだよ!
はい、リスト全体を比較するときは変数をそのまま使えばいいだけでした
めでたし めでたし
0 件のコメント:
コメントを投稿