jeudi 27 mai 2021

Python - How to write only 'if' in one line?

When I write the following it gives me an error, but I need to write it like this (in one line) how to solve it.

this works

if c:
    for y in r: img += '   '

this doesn't

if c: for y in r: img += '   '

syntax error

File "<string>", line 12
if c: for y in r: img += '   '
^
SyntaxError: invalid syntax

Aucun commentaire:

Enregistrer un commentaire