'How to do multiline python code in .kv file

So going with this short example:

GridLayout:
    id: matrixA
    cols: 1
    Button:
        on_press:
            for i in range(root.matrixArows):\
            for j in range(root.matrixAcols):\
            print(i)
            

I want to make nested for loop in my kivy file, however it keeps returning the error.enter image description here

The root.matrixArows and cols exists and is being read propely for sure, I don't know if I am making something wrong with the syntax on multiline code.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source