Computer Science, asked by arceus87, 9 months ago

what is multiple assigment in python ​

Answers

Answered by shubham0204
1

Answer:

See below.

Explanation:

In Python, we can assign some value to a variable like,

x = 1

x = 'Hello'

We can assign multiple values to their corresponding variables,

x , y = 1 , 2

Here, you can observe that there are equal number of values on both the sides.

If we return multiple values from a method like,

def foo ():

   return 'Hello' , 'Python'

Now, we have two ways to get the value from the method.

1) x , y = foo()

  print( x , y )

2) x = foo()

   print( x[0] , x[1] )

Answered by niko48
2

Answer:

Multiple assignment (also known as tuple unpacking or iterable unpacking) allows you to assign multiple variables at the same time in one line of code. This feature often seems simple after you've learned about it, but it can be tricky to recall multiple assignment when you need it most.

Explanation:

Similar questions