LoginSignup
0
0

More than 3 years have passed since last update.

Pythonで文字の一致 (paizaランク D 相当)を解く

Posted at

初めに

paizaのレベルアップ問題集を解いていたのですが、模範解答がなかったので自分で作ってみました。
言語はPython3です。

問題

Paizaのスキルチェック見本問題 文字の一致 (paizaランク D 相当)
https://paiza.jp/works/mondai/skillcheck_sample/diff_str?language_uid=python3
ログインしないと問題文が見れませんでした。
登録は無料ですぐにできるので、とりあえず登録してみることをおススメします。

解答コード

diff_str.py
# 入力された文字列を保存する
a = input()
b = input()

# 文字列を比較し答えを出力する
if a == b:
    print("OK")
else:
    print("NG")

解答コード その2

頑張って一文で書くとこんな感じになりました。
これが一般的なのですかね?

diff_str.py
print("OK" if input() == input() else "NG")

参考

最後に

分からないところがあれば気軽にコメントしてくださいね。
できるだけ答えますよ!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0