+ 1
Tuple assignment
When we assign multiple values to the single variable in python why that variable treat as a tuple in python https://code.sololearn.com/c6J6bNExMFZO/?ref=app
1 Réponse
+ 1
Tuples can be created without the parentheses, by just separating the values with commas.
#1 Words = "one" , "two" ,"three"
print(Words)
Gives :
>>> ('one' , 'two' , 'three')
#2 point = 10, 20, 30
>>> x, y, z = point
>>> print(x, y, z)
gives :
10 20 30
When you assign more than one variables then it would tuple because if there are multiple variables on left side you can have multiple values on right but if you one variable on left and multiple on right it takes all of them as tuple , if you place all of values in [] it considers it as list.
hope this helps you
https://note.nkmk.me/en/JUMP_LINK__&&__python__&&__JUMP_LINK-multi-variables-values/#:~:text=Assign%20multiple%20values%20to%20multiple%20variables,-You%20can%20assign&text=If%20there%20is%20one%20variable,is%20assigned%20as%20a%20tuple.&text=If%20the%20number%20of%20variables,appending%20*%20to%20the%20variable%20name.
https://treyhunner.com/2018/03/tuple-unpacking-improves-python-code-readability/
https://www.sololearn.com/learn/Python/2485/