Open main menu

CDOT Wiki β

Changes

OPS435 Python Lab 3

99 bytes added, 09:40, 3 June 2017
PART 2 - Manipulating Items in Lists
help(list_of_numbers.index)
list_of_numbers.index(number) # Return index of the number searched for
</source>:#The problem One common annoyance that comes up here is if the item searched can occur when performing searches are error messages when performing a search for doesn't an element that happens NOT to exist, Python will throw a error. Lets make sure it exists before asking for in the index locationlist. To find out A good way to prevent those type of errors is to use a logic statement to check to see if a the value for an element is in a list, just ask using a if statement, if the statement is True, then the appropriate search can be performed for that existing element value is found in .<br><br>:#Issue the list.following:<source>
list_of_numbers = [ 1, 5, 2, 6, 8, 5, 10, 2 ]
number = 10
13,420
edits