I am trying to add a value to a variable and print it, in the same one line if loop.
First i tried to separate my 2 actions with a ,
:
test = 0
if True : test = 4, print(test)
> 0
print (test)
> (4, None)
I don't uderstand why my variable get the value 0 when printed from the if. Outside i get a list, like test value is 4, print(test)
After i tried to use and
between 2 actions :
test = ""
if True : test = "hello" and print(test)
>
print(test)
> None
I think my variable is trying to get the value : test and print(toto)
Do you know if and how can i do multiple actions in a single line if loop ?
(sorry for possible duplicate but i keep matching answers for multiple condition in one if loop)