Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 3

39 bytes added, 09:59, 3 June 2017
PART 2 - Manipulating Items in Lists
:#Issue the following:<source>
list_of_numbers = [ 1, 5, 2, 6, 8, 5, 10, 2 ]
number = 107
if number in list_of_numbers: # Returns True if value in list, returns False if item not in list
number_index = list_of_numbers.index(number)
print('index is: ' + number_index)
else: # If the statement is False, the else will run
print(str(number) + ' is not in list_of_numbers')
</source>
13,420
edits