Accessing an initialized variable value outside a for loop? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 7

Accessing an initialized variable value outside a for loop?

I want to access the value of a variable inside a for loop outside of it without using a nested loop. i will be accessing the value of the first for loop variable value to use as a condition in the second for loop.. i would declare/initialize the variable outside the the first for loop but im not sure if the value would change? plus im not certain how to write a for loop with a variable declared/initialized outside. Any help would be great thanks

24th Oct 2017, 11:11 AM
D_Stark
D_Stark - avatar
2 Answers
+ 3
https://code.sololearn.com/c4FP5puYwnG9/?ref=app or for(i=2;i<6;i++) if you have declared variable.
24th Oct 2017, 2:39 PM
shobhit
shobhit - avatar
+ 4
thanks @shobhit thats actually what i ment.
24th Oct 2017, 3:40 PM
D_Stark
D_Stark - avatar