Recap - Format
Part of the Fundamentals section of Coddy's Rust journey — lesson 72 of 75.
Challenge
BeginnerCreate 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
> 3The output would be:
> Generated password: 123Try 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
4Operators Part 1
Arithmetic OperatorsModulo OperatorArithmetic ShortcutsComparison OperatorsString Comparison5Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 33Variables Part 2
Type DeclarationNaming ConventionsType InferenceRecap - Initialize VariablesType Casting9Loops
For Over SeriesWhile LoopBreakContinueNested LoopLoop LabelsInfinite LoopRecap - Dynamic Input