学習記録
- 今日は if と else を学びました。これは条件分岐文です。意味は、もし(条件が真なら)ここを実行し、そうでなければここを実行する。"==" は、両側の内容が等しいかどうかを意味します。
- if の条件は二重等号であり、単一等号は代入です。
- if の条件後と else の後には両方ともコロンを追加する必要があります。
- if と else の後の文はインデントする必要があり、より正確にはコロンの後の次の行をインデントする必要があります。
コード
sp=input("Do you like 'hanging aroud'?:" )
if sp == "NO":
print("Then you're not Spider-man")
else:
print("Yor are Spider-man")
korg=input("Do you have a 'gravelly' voice?: ")
if korg=="NO":
print("Aww, then you're not korg")
else:
print("You are krog")
mar=input("Do you often feel 'Marvelous'?: ")
if mar=="NO":
print("Then you are not Caption Marver")
else:
print("Aha! You're Caption Marver! Hi!")