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

תוכן שנמחק תוכן שנוסף
Mathreturn (שיחה | תרומות)
Mathreturn (שיחה | תרומות)
שורה 8:
 
* name הוא ערך הפריט לפי סדרו ברשימה. מאחר שהשם הוא ערך ניתן לבצע עליו פונקציות.
<source lang = "python">
 
str_L=['1','2','3']
int_L=[]
 
# convent str in str_L to int
for i in str_L :
int_L.append(int(i))
 
print(int_L)
 
#what type of the items in the list?
for i in int_L:
print(type(i))
 
[1, 2, 3]
<class 'int'>
<class 'int'>
<class 'int'>
</source>
 
* lst היא רשימה
* action הפעולה שתבוצע.
שורה 52 ⟵ 31:
</pre>
}}
 
===פעולות על פריטים ברשימה===
<source lang = "python">
 
str_L=['1','2','3']
int_L=[]
 
# convent str in str_L to int
for i in str_L :
int_L.append(int(i))
 
print(int_L)
 
#what type of the items in the list?
for i in int_L:
print(type(i))
 
[1, 2, 3]
<class 'int'>
<class 'int'>
<class 'int'>
</source>
 
==לולאת for ו-range==