mardi 27 août 2019

is there a way to print the value being evaluated in an if statement without having to store it in a variable? [duplicate]

This might be a silly question, but I am wondering if there is a way to print or use the value being evaluated in an if statement without having to store it in a variable first before evaluating it?

something similar to this sort of syntax:

if value_of_really_long_expression == True:
    print(value_of_really_long_expression)

of course this can be achieved by:

x = value_of_really_long_expression

if x == True:
    print(x)

purely out of interest/curiosity, I am wondering if this is even possible

Aucun commentaire:

Enregistrer un commentaire