Python assignment

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2024 Jun 6 17:13
Editor
Edited
Edited
2024 Jun 6 17:14
Refs
Refs

Walrus operator

The walrus operator (:=) allows you to assign a value to a variable within a conditional expression.
if number := int(input("Enter a number: "), base=10) > 0:     print(f"The number {number} is positive.") else:     print(f"The number {number} is non-positive.")
 
 
 
 
 
 
 
 

Recommendations