+ 2

for loop conditions..

In C, it's pretty clear how to use for loops since all the conditions are set, 1. ex. {i<10} = condition set 2. ex. {i=0}=also variable(i) used in "counting" is assigned first, 3. ex. {i++}=and even changed by either Increments or decrement but in Python this "in" concept is bugging me https://code.sololearn.com/cQn1moES5htt/?ref=app https://code.sololearn.com/cQn1moES5htt/?ref=app

13th Aug 2017, 10:37 AM
Uri vath
Uri vath - avatar
4 odpowiedzi
+ 6
Sorry for the wait... here's a possible solution for you: https://code.sololearn.com/cN8ol2hkA5sb/?ref=app
13th Aug 2017, 1:39 PM
LynTon
LynTon - avatar
+ 8
https://code.sololearn.com/cswvlWMg1FeL/?ref=app variable i is use to read the value in array. you don't want to create another variable. this condition is looping in the array.
13th Aug 2017, 10:56 AM
Nithiwat
Nithiwat - avatar
+ 6
So there the "for i in list[j]" basically means "for every value in list[j]" (you don't necessarily have to use 'i', you can use any word you haven't used yet like 'x', 'number' or even 'tyrannosaurus') and as here j = 0 and the only value in list[0] is "e" it will just print that out. To prove this if you change 'list[j]' to just 'list' you'll notice that it will go through every value of the 'list' and it will keep looping and going through every value until there are none left in 'list'.
13th Aug 2017, 11:06 AM
LynTon
LynTon - avatar
0
@LP4 how can i access list contents by skipping 1 object after accessing the other, till the end as shown in the code inserted without using range, but using list as an argument for "for loop"..... <i.e> for i in list: like this..... https://code.sololearn.com/cN7RwIAIDkWi/?ref=app
13th Aug 2017, 12:34 PM
Uri vath
Uri vath - avatar