#!/usr/bin/python3 # create a list of numbers #L = [5, 2, 10, 0, 3, 1] # create a list of random numbers import random L = [] for i in range(0, 10): L.append(random.randint(0,100)) print(L) # Algorithm is - # Set a variable to be the "smallest seen so far", initialize # it to the first number in the list, loop through the rest of # the list and update it each time you see something smaller. # loop through the values in the list, pick out the smallest smallest = L[0] for num in L: if num < smallest: smallest = num print('Smallest is', smallest) # or # loop through the indices of the list, pick out index of smallest smallest_i = 0 for i in range(0, len(L)): if L[i] < L[smallest_i]: smallest_i = i print('Smallest is', L[smallest_i], 'at index', smallest_i)