Menu
Coddy logo textTech

Recap - True or False

Part of the Fundamentals section of Coddy's Swift journey — lesson 36 of 86.

challenge icon

Challenge

Easy

Read a string input and determine whether it represents a "truthy" or "falsy" value.

You will receive the following input:

  • A single line containing a string (e.g., "yes", "no", "1", "0")

Use readLine() to read the input and safely unwrap it with if let. Then check the value:

  • If the input is "yes", "true", or "1", print true
  • If the input is "no", "false", or "0", print false

Print: Either true or false based on the input value

Try it yourself

// Read input
if let input = readLine() {
    // TODO: Write your code below
    // Check if input is "yes", "true", "1" -> print true
    // Check if input is "no", "false", "0" -> print false
    
}

All lessons in Fundamentals