Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

for_loops

# for loops
x = [ 0 for i in range(10)]
print(x) 			 # 0,0,0,0,0,0,0,0,0,0
y = [ i for i in range(10) if i%2 == 0]
print(y)			                # 0,2,4,6,8
z = [ i*j for i in range(3) for j in range(3)]
print(z)			                # 0,0,0,0,1,2,0,2,4
k = [[0 for _ in range(3)] for _ in range(3)] 
print(k)			               # [0,0,0],[0,0,0],[0,0,0]
s = [ i for i in 'hello']
print(list(s)) 			# ['h','e','l','l','o']
print(tuple(s))			# ('h','e','l','l','o')

 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
6+8 =