iteration python 3

Hosein Fard Hosein Fard Hosein Fard · 1402/4/31 12:20 ·

حلقه (while ) 

ایده اصلی اینه که یه کاری چند بار اتفاق بیوفته 

name = input("what is your Name ! : ")

while name != "end":

    print ("hello" , name)

    name = input("whats your name : ")


n = 0

while n <= 10:

    print(n)

    n = n + 1

   


 حلقه for 

حلقه ایی که به تعداد مشخصی که ما میدونیم اجرا میشه 


friends = ['ali', 'reza' , 'qasen']

count = 0

for i in friends:

    print('hello' , i)

    count = count + 1

print("i tould " , count ,"time friends hello")