Why i value is not increasing | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Why i value is not increasing

I have created a code where you can swipe left or right, there are three screens black, red, green And I can't able to swipe from red(i=1) to green(i=2) As the i value remains at 1. Here's my code https://code.sololearn.com/WtGXNVEr7gVN/?ref=app line 26 you can see the increment of i

10th Sep 2020, 5:53 AM
v@msi😉
v@msi😉 - avatar
2 Answers
+ 4
You need to declare i in the global scope.
10th Sep 2020, 6:01 AM
Rowsej
Rowsej - avatar
+ 3
Thanks it works, but can you tell me the reason. Although I declared the variable inside the function and used inside function not outside Edit:OK now I got it, every time I calls the function it assign the value i =0, that's silly mistake😟 Thanks Rowsej 🙂
10th Sep 2020, 6:06 AM
v@msi😉
v@msi😉 - avatar