Files
Learn-Python-Programming-Th…/ch03/walrus.if.py
T
adii1823 8b802c5c62 ch03
2021-10-28 17:34:45 +05:30

13 lines
293 B
Python

value = 42
modulus = 11
# Without assignment expression:
remainder = value % modulus
if remainder:
print(f"Not divisible! The remainder is {remainder}.")
# Rewritten with assignment expression:
if remainder := value % modulus:
print(f"Not divisible! The remainder is {remainder}.")