0

[SOLVED] Print something when second loop occured

println!("guess number between 1 - 20"); println!("Please input your guess"); loop { println!("Try again.."); let mut user_guessed = String::new(); io::stdin() .read_line(&mut user_guessed) .expect("your input guessed wasn't a valid number!"); let user_guessed: u32 = match user_guessed.trim().parse() { Ok(u32) => u32, Err(_) => { println!("Please enter a number!"); continue; }, }; I want the first time this code is run don't print "Try again.." and when it's loop for second time or more and then print that "try again..", How to do that?.

9th Feb 2022, 6:07 AM
EsaKurniawan
4 Réponses
0
whats the error?
9th Feb 2022, 6:28 AM
Glitching shift Sans
Glitching shift Sans - avatar
0
No error actually
9th Feb 2022, 6:37 AM
EsaKurniawan
0
I just want the first time code run don't print "try again.."
9th Feb 2022, 6:38 AM
EsaKurniawan
0
Already solved it
9th Feb 2022, 8:18 AM
EsaKurniawan