0
Help me explain this code plzz
p,p,p=1,2,3 print(p,p,p) #Output: #3 3 3
4 ответов
+ 7
it's same as doing:
p = 1
p = 2
p = 3
+ 3
first line destructure tuple (1,2,3) in p for each values, so only last one remain in p...
+ 3
When providing multiple value to a single variable, the variable only stores the last assigned value that's why p stores 3, and while printing only outputs 3 as value
+ 1
p,p,p=1,2,3 is the same as:
p=1
#assigned p variable value 1
p=2
#assigned p variable value 2
p=3
#assigned p variable value 3
#and now we print the same variable p just 3 times!