YouTip LogoYouTip

Python3 Func Reversed

# Python3.x Python3 reversed() Function [![Image 3: Python3 Built-in Functions](#) Python3 Built-in Functions](#) * * * ## Description The `reversed()` function returns a reverse iterator. ### Syntax Here is the syntax for `reversed()`: reversed(seq) ### Parameters * seq -- The sequence to be reversed. It can be a tuple, string, list, or range. ### Return Value Returns a reverse iterator. * * * ## Examples The following example demonstrates the use with a tuple: ## Example #!/usr/bin/env python3# String seqString = 'Tutorial'print(list(reversed(seqString)))# Tuple seqTuple = ('R', 'u', 'n', 'o', 'o', 'b')print(list(reversed(seqTuple)))# range seqRange = range(5, 9)print(list(reversed(seqRange)))# List seqList = [1, 2, 4, 3, 5]print(list(reversed(seqList))) The output of the above example is: ['b', 'o', 'o', 'n', 'u', 'R']['b', 'o', 'o', 'n', 'u', 'R'][8, 7, 6, 5][5, 3, 4, 2, 1] [![Image 4: Python3 Built-in Functions](#) Python3 Built-in Functions](#)
← Bootstrap4 InstallPython3 Func Bytes β†’