Python - Comma after a number within a tuple, what does it do? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python - Comma after a number within a tuple, what does it do?

zzz = ((123,)) + (456,) print(zzz) #outputs (123, 456) Aside from preventing mathematical evaluations, are there any other purpose for having the commas in line 1?

12th Oct 2020, 9:43 PM
Solus
Solus - avatar
1 Answer
+ 4
it makes it a tuple. otherwise itd just be a number in some parenthesis. try stuff out
12th Oct 2020, 10:00 PM
Slick
Slick - avatar