multiple-assignment

multiple assignments in one line for loop python

multiple assignments in one line for loop python Question: I would like a one line way of assigning two variables to two different values in a for loop. I have a list of list of values list_values = [[1, 2, 3], [4, 5, 6]] I have tried to do this, and it works but is …

Total answers: 2

Multiple assignment and evaluation order in Python

Multiple assignment and evaluation order in Python Question: What is the difference between the following Python expressions: # First: x,y = y,x+y # Second: x = y y = x+y First gives different results than Second. e.g., First: >>> x = 1 >>> y = 2 >>> x,y = y,x+y >>> x 2 >>> y …

Total answers: 11