how to loop the length of an array pytoh
array = range(10)
for i in range(len(array)):
print(array[i])
how to loop the length of an array pytoh
array = range(10)
for i in range(len(array)):
print(array[i])
python loop through list
list = [1, 3, 6, 9, 12]
for i in list:
print(i)
list loop python
list = [1, 3, 5, 7, 9]
# with index
for index, item in enumerate(list):
print (item, " at index ", index)
# without index
for item in list:
print(item)
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'
for element in array python
itemlist = []
for j in range(len(myarray)):
item = myarray[j]
itemlist.append(item)
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