+ 1
I didn't understand for and in
Help me i didn't understand for and in :/
3 Respostas
+ 1
for in loop, is used to iterate through the elements of an object.
Example: Say you want to circle through the elements of a list and print their squares.
nums = [2, 4, 1, 8, 7]
for num in nums:
print(nums**2)
Output
========
4
16
1
64
49
On the first iteration of the loop, the variable "num" is given the value 2, it then prints out 2², which is 4.
On the second iteration of the loop, the variable "num" is given the value "4" it then prints out 4² which is 16.
The loop goes on like that doing the same thing for every element in the list.
+ 3
Check this link from here you can learn it.
https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_for_loops.asp
+ 1
thank's a lot bros