Linear Search using python
<p>Hi I am new to python and I am trying to learn it by writing linear search in python here is the code and this is the code I have written so far. </p>

<pre><code>a = [100]

n = int(raw_input("Enter the no. of elements: "))

print "Enter the elements: "
for i in range(0,n):
    print i

item = int(raw_input("Enter the item to be searched: "))

for i in range(0,10):

    if a[i] == item:
        print "Item ", item, "found at location", i+1
        break;

if i == n:
    print "Item", item, "not found"
</code></pre>

<p>I get a error saying list index out of range, where am I going wrong? </p>

<p>slightly different (the sort algorithm)</p>

<pre><code>a = []

n = int(input("enter number of elements: "))

print("appending elements: ")

for i in range(0, n):
    a.append(i)
    print(i)

item = int(input("enter the item to be searched: "))
# for python2.x please use raw_input

for i in range(len(a)):
    print("searching...")
    if a[i] == item:
        print("found! at: %s" % i)
        break
    else:
        print("pretty bad day, nothing found!")
</code></pre>

python