+ 1

explain walrus code

print (num:=int(input())) how this works

16th Sep 2022, 11:36 PM
Keshav T M
Keshav T M - avatar
2 Answers
+ 8
The walrus operator is a bit controversial and not very commonly used, but it's basically for both evaluation and assignment. This code prints the number inputted and also saves it to the variable called "num".
17th Sep 2022, 1:11 AM
Daniel C
Daniel C - avatar