Can any please explain me 'for loop' | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can any please explain me 'for loop'

16th Feb 2020, 12:46 PM
Saurabh Sen
Saurabh Sen - avatar
5 Answers
+ 1
By asking this, I suppose that you have a programming knowledge of any language before? For other language, for loop is for (var i = 0; i < 10; i++) For Python, for loop is for i in range(10): That's the synatx of for loop in Python, which you have to accept. If you are working with a list, you can simply for item in list:
16th Feb 2020, 2:27 PM
Gordon
Gordon - avatar
+ 1
Now I see that you are in this lesson. https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2435/ I see that you are using for loop on list https://code.sololearn.com/cdwfmj3fa0J7/?ref=app The third page of this lesson teaches that you can also use for loop on range() for repeating a number of times. Please don't upvote your own question, and please don't pursue virtual achievements such as badges.
16th Feb 2020, 12:51 PM
Gordon
Gordon - avatar
+ 1
Listen i am just asking that why "i in" like words or something else is used in for loop
16th Feb 2020, 1:02 PM
Saurabh Sen
Saurabh Sen - avatar
0
The for loop is used when you know in advance how many times the script should run.
17th Feb 2020, 4:52 PM
ℓєgιση αятιѕт
ℓєgιση αятιѕт - avatar
0
Gordon yes you are right i had studied c language first 😋
19th Feb 2020, 3:28 PM
Saurabh Sen
Saurabh Sen - avatar