DEV Community

Discussion on: Data Types in Python

Collapse
 
michaelcurrin profile image
Michael Currin • Edited

Some notes

This is very uncommon. Possibly I've never seen this

# singleton tuple
single = 2,
print(single)
Enter fullscreen mode Exit fullscreen mode

Rather add the brackets.

single = (2,)
Enter fullscreen mode Exit fullscreen mode

This is incorrect and needs comma.

# tuple with strings
string_tuple = ('Hello')
Enter fullscreen mode Exit fullscreen mode

Simply adding brackets is meaningless there.

Make sure to add the comma:

# string
a = ("Hello")
# "Hello"

# tuple
b = ("Hello",)
# ("Hello",)
Enter fullscreen mode Exit fullscreen mode
Collapse
 
princeibs profile image
Suleiman Ibrahim

Thank you for the review on the string_tuple variable. It was a typo. I'll effect the change immediately.