why wé put comma after an item | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why wé put comma after an item

5th Nov 2016, 3:11 PM
amir mahir
amir mahir - avatar
4 Answers
+ 2
I wonder if you're in a country that uses "." for thousands and "," for decimal like: 77.000,00 Python (and many others) delimit by commas; it's a "convention" to improve clarity: one of Python's goals. And...Python was developed where commas separate groups: 77,000.00 Other languages (like Octave) are fine with just spaces...sometimes; that's their convention (perhaps related to Octave working a lot with numbers). Like currency notation, that's all it is.
6th Nov 2016, 7:17 PM
Kirk Schafer
Kirk Schafer - avatar
+ 2
Also found this: Python tuple "trailing comma" syntax rule: http://stackoverflow.com/questions/7992559/python-tuple-trailing-comma-syntax-rule It ensures that a single item is interpreted as a tuple and by convention avoids a syntax trap. See the link.
10th Nov 2016, 9:09 PM
Kirk Schafer
Kirk Schafer - avatar
+ 1
To separate them. If it weren't there, how would you make a difference between [100 100] (being one element) and [100, 100] ?
5th Nov 2016, 3:15 PM
Pierre Varlez
Pierre Varlez - avatar
0
thank you
10th Nov 2016, 8:54 PM
amir mahir
amir mahir - avatar