ํ์ด์ฌ์ ์กฐ๊ฑด๋ฌธ if, else, elif ๊ทธ๋ฆฌ๊ณ and ์ or ์ ์ดํดํฉ๋๋ค.
- if ์กฐ๊ฑด์ ๋ํ ์คํ๋ฌธ์ ๋ค์ ํ์ผ๋ก ๋ด๋ ค๊ฐ tab or space 2์นธ์ผ๋ก ๊ตฌ๋ถํฉ๋๋ค.
- ์กฐ๊ฑด์ ๋ถํฉํ๊ณ ํด๋น ์กฐ๊ฑด๋ฌธ์ ์คํ๋ฌธ์ ์งํํ๊ณ ๋๋ฉด ํ๋ก๊ทธ๋จ์ ์ ์งํฉ๋๋ค.
- if / else / elif ๋ชจ๋ ์กฐ๊ฑด๋ถ๋ก ์ฝ๋๋ฅผ ์คํํ ์ ์๊ฒ ํด์ค๋๋ค.
password_correct = True
if password_correct:
print("password clear")
else:
print("password error")
winner = 10
if winner > 10:
print("Winner is greater than 10")
elif winner < 10:
print("Winner is less than 10")
else:
print("Winner is 10")