+ 1

This code isn't running, what'd be the problem?

for n in range (5): for i in range (4): print(i) print(n)

25th Aug 2024, 7:45 AM
Aaron Paul
Aaron Paul - avatar
4 Réponses
+ 4
The variable names in the for are both i, but you want to print i and n. Change the first for with for n in range
25th Aug 2024, 7:57 AM
Ruben
+ 3
> the inner loop does not have a correct indentation for `print(i)` > also the outer loop with `print(n)` has an incorrect indentation. *in general*: try to read and understand the error messages from python. they are clearly pointing out the issues and the line number where the issue happens.
25th Aug 2024, 9:36 AM
Lothar
Lothar - avatar
+ 1
There are some errors here: Both for loops have the same variable name, which will lead to strange behavior But variable n isnt defined, so the code wont even run You should change the i in the first loop to a n, so it will work Hope this helps :)
25th Aug 2024, 8:45 AM
Ugulberto Sánchez
Ugulberto Sánchez - avatar
0
'print(i)' must be indented
27th Aug 2024, 5:58 AM
George Levi
George Levi - avatar