Questions tagged [multiple-assignment]
35 questions
0
votes
1 answer
Multiple assignment from method results in TypeError: Int is not iterable in Python
I am on a basic problem which outputs the number of coins types to be used to reach a sum which is inputted at method call.
Although I could do it in some other ways, I wanted to create a method and wanted to use multiple assignments.
The divide…

devwanderer
- 75
- 2
- 9
-1
votes
1 answer
Multiple assign to previously defined variables in Perl
How to assign return values to previously declared variables in Perl? Is there a way to do something like this:
use strict;
use warnings;
my ($a, $b, $c) = first_assign();
# let's say $a = "a", $b = "b", $c = "c"
($a, $b, $c) = second_assign();
#…

melkun
- 1
- 2
-1
votes
4 answers
Don't understand this code showing tuple unpacking
Question: Could someone explain the output? Why is z equal to 2 in the second print()?
Code:
x=1
y=2
x,y,z=x,x,y
print(y,x,y,z)
z,y,z=x,y,z
print(x,y,z)
Output:
1 1 1 2
1 1 2

Arun Upreti
- 28
- 4
-2
votes
3 answers
When splitting data to a hash data structure, what is the syntax for multiple assignment?
I am going through the "Head First" Learn to Program text for python 2.7, and as I was working through one of the exercises. It gave me a clue to multiple assign a line of data while splitting it. And since I could not guess it, I went to the…

Steven Torman
- 3
- 2
-6
votes
1 answer
Tuple assignment in Java
Unlike Python, Java doesn't natively support tuples. Therefore, is doesn't provide such a useful possibility as tuple assignment.
How would you implement it? Your solution should:
Be as universal as possible.
Be as readable as possible.
Contain no…

John McClane
- 3,498
- 3
- 12
- 33