What does the following code give us?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bansalhimani
    New Member
    • Dec 2018
    • 5

    What does the following code give us?

    What does the following code give us?
    >>> b=(1)
  • dukool sharma
    New Member
    • Dec 2018
    • 9

    #2
    Not a tuple. This gives us a plain integer.

    >>> type(b)
    <class ‘int’>
    To let it be a tuple, we can declare so explicitly with a comma after 1:

    >>> b=(1,)
    >>> type(b)
    <class ‘tuple’>
    Last edited by Rabbit; Jan 15 '19, 05:32 PM. Reason: link removed

    Comment

    Working...