From a book that programmers can learn ... (Python): Review of arrays

In the item of array review Studying python list

From getting and searching arrays *** Search for a specific value ***. Answer code in C ++
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++;

My Python code
#!/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

From a book that programmers can learn ... (Python): Review of arrays
From a book that programmers can learn ... (Python): Pointer
From a book that programmers can learn ... (Python): About sorting
From a book that programmers can learn (Python): Decoding messages
From a book that programmers can learn (Python): Statistical processing-deviation value
From a book that programmers can learn (Python): Conditional search (maximum value)
From a book that programmers can learn: Verification of rune checksum (fixed length)
From a book that programmers can learn (Python): Class declaration (public / private, etc.)
From a book that programmers can learn ... Verification of rune checksum (variable length) Part 2
From a book that programmers can learn ... Collect small problem parts
From a book that makes the programmer's way of thinking interesting (Python)
From a book that programmers can learn: Converting characters that represent numbers to integer types
Programmer's way of thinking is from XX book (Python)
Programmer's way of thinking is from XX book (Python)
8 services that even beginners can learn Python (from beginners to advanced users)
A memorandum of calling Python from Common Lisp
"Python Kit" that calls a Python script from Swift
A class for PYTHON that can be operated without being aware of LDAP
I made a Docker image that can call FBX SDK Python from Node.js
[Python] A program that counts the number of valleys
A python script that gets the number of jobs for a specified condition from indeed.com
Make a copy of a Google Drive file from Python
Python points from the perspective of a C programmer
Python that merges a lot of excel into one excel
"A book that understands Flask from scratch" Reading memo
The attitude that programmers should have (The Zen of Python)
A mechanism to call a Ruby method from Python that can be done in 200 lines
[Python] A program that compares the positions of kangaroos.
A library that monitors the life and death of other machines by pinging from Python
How to start a simple WEB server that can execute cgi of php and python
A Python script that allows you to check the status of the server from your browser
[Python] A program to find the number of apples and oranges that can be harvested
Is your dll a dll that can take advantage of multi-core?
A memo that reads data from dashDB with Python & Spark
A Python program in "A book that gently teaches difficult programming"
Different from the import type of python. from A import B meaning
python Condition extraction from a list that I often forget
I want to start a lot of processes from python
Python: Create a dictionary from a list of keys and values
Python> Read from a multi-line string instead of a file> io.StringIO ()
Iterator that can scan forward from the middle of the sequence
A Python program that aggregates time usage from icalendar data
A set of script files that do wordcloud in Python3
A Python script that compares the contents of two directories
python> Handling of 2D arrays
[Python] A program that finds the maximum number of toys that can be purchased with your money
Create an instance of a predefined class from a string in Python
[Python] Make a graph that can be moved around with Plotly
I made a package that can compare morphological analyzers with Python
Investigation of DC power supplies that can be controlled by Python
Make a Kindle book that images mathematical formulas from TeX files
A formula that simply calculates the age from the date of birth
A story that struggled to handle the Python package of PocketSphinx
Created a library for python that can easily handle morpheme division
About psd-tools, a library that can process psd files in Python
TensorFlow To learn from a large number of images ... ~ (almost) solution ~
[Python] Get the update date of a news article from HTML
A function that measures the processing time of a method in python
I made a shuffle that can be reset (reverted) with Python
[Python algorithm] A program that outputs Sudoku answers from a depth-first search
Introduction of ls command lsix that can display a list of images