I have a simple question. I saw so many times that my teammates use ,) like in a tuple (Python, bash scripts, etc.)
Example:
animals = ("Parrot",)
What's the purpose of this? Is it like a wildcard?
I have a simple question. I saw so many times that my teammates use ,) like in a tuple (Python, bash scripts, etc.)
Example:
animals = ("Parrot",)
What's the purpose of this? Is it like a wildcard?
What you're seeing is the way to create a tuple containing just one element, the string "Parrot". Without the comma, you'll end up with the string "Parrot" and no tuple. It wouldn't be good to cause ("Parrot") to create a tuple, because you ought to be able to put a pair of parentheses around any expression without changing its meaning. The comma is needed to make it clear that you want to create a tuple.
As @Cyrus suggests, see the documentation for tuples: https://docs.python.org/3/library/stdtypes.html#tuple