Instruction
Okay, it's time to wrap things up! First, a quick review of what we've learned:
- To check if an item is present in a data structure, use the
inoperator:letters_set = {'a', 'b', 'c', 'd', 'e'} if 'c' in letters_set: print('Found!') - To sort a list in place, use the
.sort()method:names_list = ['Kate', 'John', 'Paul', 'Anne'] names_list.sort()
- To sort a list in descending order, use the
reverseargument:names_list = ['Kate', 'John', 'Paul', 'Anne'] names_list.sort(reverse=True)
- To get a sorted copy, use the
.sorted()method:words_list = ['come', 'tell', 'say', 'go', 'run'] list_sorted_ascending = words_list.sorted() list_sorted_descending = words_list.sorted(reverse=False)
- To reverse the order of elements in place, use the
.reverse()method:numbers_list = [1, 2, 3, 4, 5, 6, 7] numbers_list.reverse()
- To get a reversed copy of a list, use a
forloop and thereversed()function:numbers_list = [1, 2, 3, 4, 5, 6, 7] reversed_list = [] for item in reversed(numbers_list): reversed_list.append(item)
Good! Are you ready for a short quiz?
Exercise
Click to continue.



