פייתון/פייתון גרסה 3/רשימה: הבדלים בין גרסאות בדף

תוכן שנמחק תוכן שנוסף
Mathreturn (שיחה | תרומות)
Mathreturn (שיחה | תרומות)
שורה 7:
 
<source lang = "python">
#list concatenation
>>> list_1=['a','b','c','d','e',8]
>>> list_2L1=[1,2,3,4]
>>> list_1L2=['a','b','c','d','e',8]
>>> list_1+=list_2
>>> L1+L2
#list_1+ means take list_1+list_2
[1, 2, 3, 'a', 'b', 'c']
>>> list_1
#list repetition
['a', 'b', 'c', 'd', 'e', 8, 1, 2, 3, 4]
>>> L1=[1,2,3]
>>> L1*3
['a'1, 'b'2, 'c'3, 'd'1, 'e'2, 83, 1, 2, 3, 4]
 
</source>