Iterable Functions w/ For Loops
Last updated
Last updated
We will be exploring more functions similar to range()
where they also return an iterable sequence that we can iterate through with a for loop
The sorted()
function will return a sorted list in order from least to greatest from a sortable sequence.
For strings, they follow their .
For lists, it will depend on the datatype of each item. It is recommended that all the items have the same data type in the list if you are using sorted.
The result of a sorted()
is printable as it returns a list
The result of enumerate()
is not printable
The reversed()
is a simple function that reverses any given sequence.
The result of reversed()
is not printable
The enumerate()
function will pair the index for each item in the given sequence argument. This allow us to do a special type of for loop that involves .