Lists in Python -


i noticed can multiply list scalar behavior weird if multiply:

[2,3,4] * 3  

i get:
[2,3,4,2,3,4,2,3,4]
understand results it's for? there other weird operations that?

the main purpose of operand initialisation. example, if want initialize list 20 equal numbers can using loop:

arr=[] in range(20):     arr.append(3) 

an alternative way using operator:

arr = [3] * 20 

more weird , normal list operation on lists can find here http://www.discoversdk.com/knowledge-base/using-lists-in-python


Comments

Popular posts from this blog

android - can not access to progress bar in an other activity -

html - Not able to access next element of an array javascript -