python loop through list
list = [1, 3, 6, 9, 12]
for i in list:
print(i)
python loop through list
list = [1, 3, 6, 9, 12]
for i in list:
print(i)
python for loop with array
foo = ['foo', 'bar']
for i in foo:
print(i) #outputs 'foo' then 'bar'
for i in range(len(foo)):
print(foo[i]) #outputs 'foo' then 'bar'
i = 0
while i < len(foo):
print(foo[i]) #outputs 'foo' then 'bar'
iterate through an array python
colors = ["red", "green", "blue", "purple"]
i = 0
while i < len(colors):
print(colors[i])
i += 1
python array looping
array = ["Var1","Var2","Var3"]
for i in range(len(array)):
print(array[i])
#Output#
#Var1
#Var2
#Var3
looping over an array python
for i in range(50):
i =+ 1
print(i)
python loop array
num = [int(d) for d in str(input("Enter the number:"))]
even,odd = 0,0
for i in range(0,len(num)):
if i % 2 ==0:
even = even + num[i]
else:
odd = odd + num[i]
print(abs(odd-even))
# code contributed by Shubhanshu Arya PrepInsta Placement Cell Student
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us