Saturday, March 11, 2017

Analyse this Python code snippet

By Vasudev Ram

Hi reader [1],

Analyze the snippet of Python code below. See what you make of it.

I will discuss it in my next post.

>>> a = 1
>>> lis = [a, 2 ]
>>> lis
[1, 2]
>>> lis = [a, 2 ,
... "abc", False ]
>>>
>>> lis
[1, 2, 'abc', False]
>>> a
1
>>> b = 3
>>> lis
[1, 2, 'abc', False]
>>> a = b
>>> a
3
>>> lis
[1, 2, 'abc', False]
>>> lis = [a, 2 ]
>>> lis
[3, 2]
>>>

[1] This product is suitable for Pythonistas aged 1 to 2 (approximately). For those of higher age, the dose may have no effect :)

- Vasudev Ram - Online Python training and consulting

Are you a blogger with some traffic? Get Convertkit:

Email marketing for professional bloggers

Get updates (via Gumroad) on my forthcoming apps and content.

Jump to posts: Python * DLang * xtopdf

Subscribe to my blog by email

My ActiveState Code recipes

Follow me on: LinkedIn * Twitter



1 comment:

Vasudev Ram said...


>This product is suitable for Pythonistas aged 1 to 2 (approximately).

Correction: for Pythonistas aged 0 to 2.

Why should we leave out those child prodigies ...