0

Examples of "for" command in phyton

can anyone give me atleast some examples of for command in phyton, I don't completely understand it

7th Apr 2017, 7:41 AM
Zara suto
Zara suto - avatar
2 Respostas
+ 13
for number in range(0,10): print(number) #run this and I think you'll get the idea. "number" can be changed to any name (i is the most common name used) and you can replace range with lists or dictionaries
7th Apr 2017, 8:05 AM
Ahri Fox
Ahri Fox - avatar
+ 3
for i in range(4): i+=1 print(i) #try this if you didn't understand mechanism. range(4) normally outputs 0 1 2 3 for takes this numbers as input variables which is named as i below. Basically it just makes the code run for every number that is in range. For an example this code adds 1 to every number that are in range 4. Finally it prints output: 1 2 3 4
14th Apr 2017, 11:28 PM
Efe Emir Pekmez
Efe Emir Pekmez - avatar