![]() |
Python String rfind() method returns the rightmost index of the substring if found in the given string. If not found then it returns -1. Python String rfind() Method Syntax
Python String rfind() Method ExamplePython3
Output: 8 Example 1: Basic usages of Python String find() MethodPython3
Output: Substring 'geeks' found at index : 10 Substring 'for' found at index : 6 Substring 'ate' found at index : 13 Example 2: Using Python String rfind() Method with given start and end position inside StringIf we pass the start and end parameters to the Python String rfind() Method, it will search for the substring in the portion of the String from its right side. Python3
Output: 10 10 -1 6 10 Example 3: Practical ApplicationHere, we check one email address and the Top Level Domain (TLD) matching our necessary condition. Then we print, “Email matched” else “Email not matched”, followed by the TLD String. Even if this email address contains a “.com” substring, rfind() helped to extract the TLD string more efficiently. Python3
Output: Email not matched, tld: .xyz |
Reffered: https://www.geeksforgeeks.org
Python |
Related |
---|
|
|
|
|
|
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |