Back to Sessions
Session 2
1 lesson completed
If Statements
CompletedAssignment
Complete check_swords_for_army. If number of swords equals number of soldiers, return 'correct amount'. Otherwise return 'incorrect amount'. Punctuation matters!
Solution
def check_swords_for_army(number_of_swords, number_of_soldiers):
if number_of_soldiers == number_of_swords:
return "correct amount"
return "incorrect amount"Concept
if/else structure, == comparison, returning strings from functions, exact string matching
How it went
Solid. Clean and correct — used if for the matching case and let fallback return sit at function level (no else). Returned all strings with correct punctuation.
Ratings
Concept grasp: Solid
Independent attempt: Good
Clean code: Good — no unnecessary else
Key takeaways
- →When a lesson says 'punctuation matters', copy strings exactly — Python string comparison is case and character sensitive