Home>

It's about the combination of Python if and for statements.
v = false
for i in range (5):
for j in range (5):
if v is false:
print ("✳︎", end == "")
v = true
else:
print ("-", end = "")
v = false
print ()

I want you to explain this in an easy-to-understand manner!
In particular, I don't know the relationship between i, j and ✳︎,-and why they alternate.

  • Answer # 1

    It ’s faster to actually see it.
    Visualize Python, Java, JavaScript, C, C ++, Ruby code execution

    After opening the link destination and waiting for a while, the following screen appears.
    You can proceed with one-step processing with the "Forward" button.

    How to write code

    StackOverflow has a function that makes it easy to see the code.
    Open the question edit screen and press the<code>button with the code selected.
    Especially in Python, if the indentation breaks, the meaning of the code changes.

    Also, when presenting code, make sure that it works correctly.
    The code presented is full of bugs.