arr=[0,1,5,8,14,15,21,26]
count=0
For i in range(Len(arr)):
If(arr[i]>=10 and arr[i]<=20):Count =1
Print(count)
I want the length of the values range between 10 and 20
CodePudding user response:
Your posted code has a few syntax errors. This should work:
arr = [0,1,5,8,14,15,21,26]
count = 0
for i in range(len(arr)):
if (arr[i] >= 10 and arr[i] <= 20):
count = 1
print(count)
CodePudding user response:
Try this:
arr=[0,1,5,8,14,15,21,26]
results = [] # If you want to save those results
count = 0
for i in range(len(arr)):
if(arr[i]>=10 and arr[i]<=20):
print(arr[i])
results.append(arr[i])
count =1
The Output:
print(results) # [14, 15]
print(count) # 2