Menu
Coddy logo textTech

Recap - Format

Part of the Fundamentals section of Coddy's Rust journey — lesson 72 of 75.

challenge icon

Challenge

Beginner

Create a program that builds a password by getting user input in different scopes. Each scope asks for different parts of the password. The final password is a combination of the whole parts. For example:

Input:

> 1
> 2
> 3

The output would be:

> Generated password: 123

Try it yourself

use std::io;

fn main() {
    // Declare your final_password variable here
    let mut final_password;
    
    {
        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();
        input = input.trim().to_string();
        // Add your code here to handle the first input

    }
    
    {
        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();
        input = input.trim().to_string();
        // Add your code here to handle the second input

    }
    
    {
        let mut input = String::new();
        io::stdin().read_line(&mut input).unwrap();
        input = input.trim().to_string();
        // Add your code here to handle the third input
    }

    println!("Generated password: {}", final_password);
}

All lessons in Fundamentals