Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

Python use number twice without variable

#The walrus operator := assigns values to variables as part of a larger expression.
#In this example, the assignment expression helps avoid calling len() twice:

if (n := len(a)) > 10:
    print(f"List is too long ({n} elements, expected <= 10)")
Source by docs.python.org #
 
PREVIOUS NEXT
Tagged: #Python #number #variable
ADD COMMENT
Topic
Name
8+2 =