Skip to content
Advertisement

python tuple ending with comma difference

What is the difference between

JavaScript

and

JavaScript

I noticed that for example mysql wrapper parameters formatting doesn’t work with the first case, it must end with comma.

JavaScript

Advertisement

Answer

if you write only one element in parentheses (), the parentheses () are ignored and not considered a tuple.

JavaScript

output: str

to generate a one-element tuple, a comma , is needed at the end.

JavaScript

ouput : tuple

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement