Python program as a whole, be it any version accepts the reverse() function for reversing the elements of the list. The below program is executed in Python 3, will produce the same output as in any Python version.
subj = ['Physics', 'Biology', 'Chemistry', 'Math']
subj.reverse()
print ("Subject List: ", subj)
Output
Subject List:Â ['Math', 'Chemistry', 'Biology', 'Physics']
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?
- 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?
- How do you reverse a list without reverse?
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