In the item of array review Studying python list
const int ARRAY_SIZE = 10;
int intArray[ARRAY_SIZE] = {4,5,9,12,-4,0,-57,30987,-287,1};
int targetValue = 12;
int targetPos = 0;
while((intArray[targetPos] != targetValue) && (targetPos < ARRAY_SIZE))
targetPos++;
#!/usr/bin/env python
#coding:utf-8
def Search(targetValue):
ARRAY_SIZE = [4,5,9,12,-4,0,-57,30987,-287,1]
for x in ARRAY_SIZE:
if targetValue == x:
return x
else:
continue
if targetValue != x:
print("not found")
・ ・ ・ ・(Terminal execution)
>>> from test33 import Search
>>> Search(12)
12
>>>
Anyway, I'm thinking with an if statement, but I wonder if this is all right. I will continue.
Recommended Posts