Ask Your Question

Is there any difference between the variables b and *b in these two statements? If so, what is it?

asked 2018-10-16 15:54:43 +0200

damodar gravatar image
        (a, b, c) = 1, 2, 3
        (a, *b, c) = 1, 2, 3
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-10-17 07:33:16 +0200

nbruin gravatar image

The second is a syntax error in Python 2. In Python 3, the second one is valid. To see the difference, print b after both cases and compare. Hint: (a, *b, c) = (1,2,3,4) does not give an error.

This is really a python question. It has very little to do with sage specifically (especially because it doesn't quite run flawlessly on python 3 yet).

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2018-10-16 15:54:43 +0200

Seen: 470 times

Last updated: Oct 16 '18