- University of Edinburgh
- University of Amsterdam
- University of Georgia
- University of Groningen
- University of Southampton
- University of Hyderabad
- IIT Hyderabad
- IISc Bangalore
- Amrita Vishwa Vidyapeetham University
Solve Problems by Coding Solutions - A Complete solution for python programming
Courses in Artificial Intelligence - Study Options
Walrus Operator in Python 3.8
One of the biggest highlights of Python 3.8.0 is a new feature for assignment expressions known as the Walrus Operator.
"There is new syntax := that assigns values to variables as part of a larger expression," the Python 3.8.0 release notes state.
"It is affectionately known as 'the walrus operator' due to its resemblance to the eyes and tusks of a walrus."
"There is new syntax := that assigns values to variables as part of a larger expression," the Python 3.8.0 release notes state.
"It is affectionately known as 'the walrus operator' due to its resemblance to the eyes and tusks of a walrus."
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)")
Subscribe to:
Posts (Atom)