In order to reverse a list without using the built-in reverse() function, we use the Slicing Operator. The slicing operator is another method used for reversing the data elements. Let us understand this by looking at an example.
info = [1, 'Raj', 2, 'Sejal', 3, 'Josh']
a = info[::-1]
print('Reversed List: ', a)
Output
Reversed List:Â ['Josh', 3, 'Sejal', 2, 'Raj', 1]
Related Questions
- How do you comment out multiple lines in Python?
- What is the use of Del in Python?
- How do you define a function in Python?
- How do you declare a global variable in python?
- How do you find the range in Python?
- How do you sort a list in Python and Python 3?
- How do I reverse a list in Python?
- What are the different types of comments in Python?
- How do you Del statement in Python?
- What is function in Python with example?
- What is a global variable in python?
- What is __ Getattr __ in Python and what it is used for?
- How do you range a number in Python?
- How do you comment out a paragraph in Python?
- What is __ del __ in Python?
- What is the function of == in Python?
- Is it OK to use global variables in Python?
- What is Getattr and Setattr in Python?
- How does Range () work in Python?
- What does sort () do in Python?
- How do you reverse in Python 3?
- What do you mean by comments in Python?
- How do I delete a command in python?
- How do you declare a global list in Python?
- How do you sort a list in descending in python?
Related Topics
- Python Lambda (Anonymous) Function
- Python *args and **kwargs (With Examples)
- Python Array of Numeric Values
- Python Assert Statement
- Python Comments (With Examples)
- Python del Statement (With Examples)
- Python Dictionary Comprehension
- Python Functions (def): Definition with Examples
- Python Function Arguments (Default, Keyword and Arbitrary)
- Python Global Keyword (With Examples)
- Python Global, Local and Nonlocal variables (With Examples)
- Python ascii()
- Python delattr()
- Python super()
- Python locals()
- Python hash()
- Python id()
- Python sorted()
- Python dict()
- Python callable()
- Python dir()
- Python next()
- Python divmod()
- Python float()
- Python bytearray()
- Python filter()
- Python issubclass()
- Python __import__()
- Python enumerate()
- Python list()
- Python input()
- Python int()
- Python complex()
- Python zip()
- Python iter()
- Python bool()
- Python hex()
- Python open()
- Python ord()
- Python Built-in Functions
- Python oct()
- Python compile()
- Python reversed()
- Python tuple()
- Python frozenset()
- Python map()
- Python setattr()
- Python len()
- Python chr()
- Python object()
- Python bytes()
- Python getattr()
- Python slice()
- Python str()
- Python sum()
- Python isinstance()
- Python bin()
- Python type()
- Python range()
- Python Dictionary items()
- Python List sort()
- Python List reverse()
- Python String strip()
- Python String join()
- Python String split()
- Python User-defined Functions
Leave a Reply