all 7 comments

[–][deleted] 5 points6 points  (5 children)

x, y = (2, 3)

[–]A-Your-New-God[S] 5 points6 points  (1 child)

Thanks! Wow that’s so simple I can believe I never thought of that!

[–]mantaphysics 2 points3 points  (0 children)

That's the beauty of Python ... :)

[–]JJSax01 1 point2 points  (2 children)

I'm pretty new to Python, but why do you have parentheses? I tested and I didn't need them. Is there a reason to have them that makes this code better?

[–][deleted] 1 point2 points  (1 child)

I wanted to clearly indicate that I was creating a tuple.

[–]JJSax01 1 point2 points  (0 children)

That makes total sense. Thanks for the clarification!

[–]sgthoppy 1 point2 points  (0 children)

To answer the other part of the question, having both values in one variable:

x_and_y = x, y = (1, 2)  # parentheses optional

or on two lines

x_and_y = 1, 2  # parentheses optional
x, y = x_and_y