+ 2

Why f=(0) is considered integer instead of tuple

While executing the code f=(0) print type(f) It returns integer as type

11th Oct 2019, 2:05 PM
Banana Face
Banana Face - avatar
3 Respuestas
+ 2
I guess because python thinks parentheses around 0 are for calculations or operators. But there's one think I'm sure about: You should use "," if you want python to recognize it as a tuple: f=(0,)
11th Oct 2019, 2:15 PM
ΛM!N
ΛM!N - avatar
+ 2
if you do: f = (0,1) the result will be tuple. The same happens if you do: f =() #or f = (0,)
11th Oct 2019, 3:22 PM
Lothar
Lothar - avatar
+ 1
Thanks a lot AMIN and Lothar
12th Oct 2019, 9:53 AM
Banana Face
Banana Face - avatar