--- id: python-else title: "Python Else" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["Python Else Statement", "파이썬 else"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.9 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["python", "programming", "w3schools", "else", "conditions"] raw_sources: ["https://www.w3schools.com/python/python_if_else.asp"] applied_in: [] github_commit: "" --- # [[Python Else]] ## 🎯 ν•œ 쀄 톡찰 (One-line insight) else is the fallback that catches everything not matched by preceding if/elif conditions, and it must always come last β€” Python doesn't allow an elif after an else. [S1] ## 🧠 핡심 κ°œλ… (Core concepts) - **`else`** β€” catches anything not caught by preceding if/elif conditions. [S1] - **Must come last** β€” no elif can follow an else. [S1] - **Works with or without elif** β€” a simple `if/else` two-way branch is valid on its own. [S1] - **Common uses** β€” error handling, validation, providing default values. [S1] ## πŸ“– μ„ΈλΆ€ λ‚΄μš© (Details) - With elif: `if b > a: ... elif a == b: ... else: print("a is greater than b")`. [S1] - Without elif (simple two-way): `if b > a: ... else: print("b is not greater than a")`. [S1] - Even/odd check: `if number % 2 == 0: "even" else: "odd"`. [S1] - Validation fallback: `if len(username) > 0: print(f"Welcome, {username}!") else: print("Error: Username cannot be empty")`. [S1] ## βš–οΈ λͺ¨μˆœ 및 μ—…λ°μ΄νŠΈ (Contradictions & updates) μ†ŒμŠ€μ—μ„œ λͺ¨μˆœλ˜λŠ” μ •λ³΄λŠ” λ°œκ²¬λ˜μ§€ μ•ŠμŒ. ## πŸ› οΈ 적용 사둀 (Applied in summary) ν˜„μž¬ 발견된 μ‹€μ œ 적용 사둀가 μ—†μŠ΅λ‹ˆλ‹€ β€” μž…λ ₯ 검증/κΈ°λ³Έκ°’ 제곡처럼 "κ·Έ μ™Έ λͺ¨λ“  경우"λ₯Ό μ²˜λ¦¬ν•˜λŠ” ν‘œμ€€ νŒ¨ν„΄μ΄λ‹€. [S1] ## πŸ’» μ½”λ“œ νŒ¨ν„΄ (Code patterns) Fallback validation pattern (Python): ```python username = "Emil" if len(username) > 0: print(f"Welcome, {username}!") else: print("Error: Username cannot be empty") ``` ## βœ… 검증 μƒνƒœ 및 신뒰도 - **μƒνƒœ:** draft - **검증 단계:** conceptual - **좜처 신뒰도:** B (W3Schools β€” widely used educational reference, not a primary standards body) - **μ‹ λ’° 점수:** 0.90 - **쀑볡 검사 κ²°κ³Ό:** μ‹ κ·œ 생성 (New discovery) ## πŸ”— 지식 κ·Έλž˜ν”„ (Knowledge Graph) - **μƒμœ„/루트:** [[Python Tutorial]] - **κ΄€λ ¨ κ°œλ…:** [[Python If Statement]], [[Python Elif]], [[Python If Shorthand]] - **μ°Έμ‘° λ§₯락:** if/elif 체인의 κΈ°λ³Έ 폴백 β€” μœ νš¨μ„± 검사/κΈ°λ³Έκ°’ μ œκ³΅μ— ν‘œμ€€μ μœΌλ‘œ μ‚¬μš©. ## πŸ“š 좜처 (Sources) - [S1] W3Schools β€” Python Else Statement β€” https://www.w3schools.com/python/python_if_else.asp ## πŸ“ λ³€κ²½ 이λ ₯ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "Python Else Statement" page (Astra wiki-curation, P-Reinforce v3.1 format).