I'm using python to write a program that, when given a list of random numbers, sorts them from lowest to highest then it asks the user for a number and it checks that number's place in the sorted list if the number is present, but i keep getting a syntax error on an "if" statement line near the end. is it because i'm not allowed to look up a number in the sorted list? here's my program with a list of example numbers (highlighted in bold is where i get the syntax error):
Code:
import random
def sort_array2_4():
unsorted_array = random.sample(xrange(1000), 10)
a=[93,84,200,513,46,1,45,334,92,96,156,82,92,46,]
def bubblesort(a):
for swap in range(len(a)-1,0,-1):
for index in range(swap)
if a[index] > a[index + 1]:
a[index], a[index + 1] = a[index + 1], a[index]
return a
while(more==True):
num=str(input("Enter a number to search for in list.\n")
[B]if (num in bubblesort(a)):[/B]
print num + "is in list at number: ", bubblesort(a).index(num)
else:
print num + "is not recognized in list"
Comment