Why type((1))
is int and not a tuple? Whereas type((1,))
gives tuple.
Asked
Active
Viewed 47 times
0
-
The (1,) syntax is the way to indicate a tuple of one element. (1) is simply 1 which is an integer. – quamrana Sep 22 '19 at 17:16
-
2Putting parentheses around something doesn't make it a tuple. – khelwood Sep 22 '19 at 17:19
2 Answers
1
That's also an answer to the question why we should use commas while defining a tuple with one value. Because tuples are not like lists which is unique in a way that we define it (using squared brackets) we have to add the comma to the value. In the first one type((1))
inner paranthesis have no effect, so it's just a basic integer nothing else. Like when you define expressions in paranthesis to give them priority. Hope it helps :)

JockyCracker
- 95
- 8