What is the difference between these two lines in Python? 👇👇👇 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the difference between these two lines in Python? 👇👇👇

a, b=0,1 #Give value to 2 variables in one line a=0 # Value to a variable in a line b=1

1st Mar 2021, 12:26 AM
Amir
Amir - avatar
5 Answers
1st Mar 2021, 1:39 AM
Amir
Amir - avatar
+ 4
I think the difference between two line that the line one use Pythonic code
1st Mar 2021, 1:02 AM
Jamal Saied
Jamal Saied - avatar
0
functionally they are identical. the first example could make your code slightly harder to read as it is less common to code that way. i prefer clean and simple code that’s easiest to read.
1st Mar 2021, 1:27 AM
Jerry Hobby
Jerry Hobby - avatar
0
@amir that’s interesting, but different. there they are talking about assignment precedence. very interesting though.
1st Mar 2021, 1:49 AM
Jerry Hobby
Jerry Hobby - avatar
0
Yes that's right. Unfortunately, I did not ask the right question
1st Mar 2021, 1:50 AM
Amir
Amir - avatar