Python - Reverse Slicing of given string Last Updated : 14 Jan, 2025 Comments Improve Suggest changes Like Article Like Report Reverse slicing in Python is a way to access string elements in reverse order using negative steps.Using Slicing ([::-1])Using slicing with [::-1] in Python, we can reverse a string or list. This technique works by specifying a step of -1, which starts at the end of the sequence and moves backward, effectively reversing the order of elements. It's a concise and efficient way to reverse strings or lists. Python s1 = "hello" s2= s1[::-1] print(s2) OutputReversed String: olleh ExplanationThe slicing syntax [::-1] starts at the end of the string and moves backward with a step of -1.Using a LoopUsing a loop to reverse a string involves iterating through each character in reverse order and building a new string. Python s1 = "hello" s2 = "" for char in s1: s2 = char + s2 print("Reversed String:", s2) OutputReversed String: olleh ExplanationEach character is added to the front of the result string, effectively reversing the order. Comment More infoAdvertise with us Next Article Python - Reverse Slicing of given string manjeet_04 Follow Improve Article Tags : Python Python Programs Python string-programs Practice Tags : python Similar Reads Python | Reverse Interval Slicing String Sometimes, while working with strings, we can have a problem in which we need to perform string slicing. In this, we can have a variant in which we need to perform reverse slicing that too interval. This kind of application can come in day-day programming. Let us discuss certain ways in which this t 4 min read Python | Reverse Incremental String Slicing Sometimes, while working with Python strings, we can have a problem in which we need to perform the slice and print of strings in reverse order. This can have applications in day-day programming. Let us discuss certain ways in which this task can be performed. Method #1: Using loops This is the brut 4 min read Python - Reversed Split Strings In Python, there are times where we need to split a given string into individual words and reverse the order of these words while preserving the order of characters within each word. For example, given the input string "learn python with gfg", the desired output would be "gfg with python learn". Let 3 min read How To Reverse A List In Python Using Slicing In Python, list slicing is a common practice and it is the most used technique for programmers to solve efficient problems. In this article, we will see how we can reverse a list using slicing in Python. Reverse a List Using Slicing in PythonBelow are some of the examples by which we can perform rev 3 min read Reverse All Strings in String List in Python We are given a list of strings and our task is to reverse each string in the list while keeping the order of the list itself unchanged. For example, if we have a list like this: ['gfg', 'is', 'best'] then the output will be ['gfg', 'si', 'tseb'].Using For LoopWe can use a for loop to iterate over th 2 min read Python | Remove the given substring from end of string Sometimes we need to manipulate our string to remove extra information from the string for better understanding and faster processing. Given a task in which the substring needs to be removed from the end of the string using Python. Â Â Remove the substring from the end of the string using Slicing In 3 min read Python - Reverse Range in String List Given a string list, reverse each element of string list from ith to jth index. Input : test_list = ["Geeksforgeeks", "Best", "Geeks"], i, j = 1, 2 Output : ['ee', 'es', 'ee'] Explanation : Range of strings are extracted. Input : test_list = ["Geeksforgeeks"], i, j = 1, 7 Output : ['eeksfor'] Explan 3 min read Python - Remove after substring in String Removing everything after a specific substring in a string involves locating the substring and then extracting only the part of the string that precedes it. For example we are given a string s="Hello, this is a sample string" we need to remove the part of string after a particular substring includin 3 min read Python - Get all substrings of given string A substring is any contiguous sequence of characters within the string. We'll discuss various methods to extract this substring from a given string by using a simple approach. Using List Comprehension :List comprehension offers a concise way to create lists by applying an expression to each element 3 min read Python - K elements Reversed Slice Given List of elements, perform K elements reverse slice. Input : test_list = [2, 4, 6, 8, 3, 9, 12, 15, 16, 18], K = 3 Output : [18, 16, 15] Explanation : 3 elements sliced from rear end. Input : test_list = [2, 4, 6, 8], K = 3 Output : [8, 6, 4] Explanation : 3 elements sliced from rear end, 8, 6 4 min read Like