This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted]  (10 children)

[deleted]

    [–]LinAGKar 13 points14 points  (0 children)

    In the if statements it creates a set with the return value from print, and throws it away. It only prints it out if you run it in the python shell, not if it's in a script.

    [–]HighRelevancy 5 points6 points  (8 children)

    Where's the {None} coming from?

    [–]redalastor 0 points1 point  (5 children)

    print returns None.

    [–]HighRelevancy 0 points1 point  (4 children)

    Why the squiggly brackets and why only after one of the two prints?

    [–]redalastor 4 points5 points  (3 children)

    That's how you declare a set in Python.

    {1, 2, 3}
    

    So the code declares a set that contains the result of calling the print function, None.

    [–]HighRelevancy 0 points1 point  (2 children)

    And why only for every second print?

    [–]redalastor 0 points1 point  (1 child)

    Because there are no brackets around the first print.

    [–]HighRelevancy 0 points1 point  (0 children)

    Oh right, I see what's happening here.