[Solved] how to modify the output [closed]


While this code is not pretty to do what your’re looking to do you need to change these lines

if num>0:
    l+='"'+ str(k) + '"=' + str(num)+' '
    True
if True:
    lst+=[l]

If you change it to something like

if num>0:
    l+='"'+ str(k) + '"=' + str(num)+' '
    flag = True
if flag:
    lst+=[l]

and then if you reinitialize the flag = False at the beginning of the for loop it should produce the results you want. by doing the if True you are saying to always append to the list vs when there is actually something in there

3

solved how to modify the output [closed]