Re.split() in Python Hacker Rank Solution

Hello coders, In this post, you will learn how to solve Re.split() in python hackerrank solution. This problem is a part of the Python Hacker Rank series.

Re.split() in python hackerrank solution
Re.split() in python – hackerrank solution

Re.split() in python hackerrank solution

problem

re.split()
The re.split() expression splits the string by occurrence of a pattern.

>>> import re
>>> re.split(r"-","+91-011-2711-1111")
['+91', '011', '2711', '1111']

You are given a string s consisting only of digits 0-9, commas ,, and dots .
Your task is to complete the regex_pattern defined below, which will be used to re.split() all of the , and . symbols in s.
It’s guaranteed that every comma and every dot in s is preceeded and followed by a digit.

Sample Input :

100,000,000.000

Sample Output :

100
000
000
000

Re.split() in python hackerrank solution

regex_pattern = r"[.,]+"	# Do not delete 'r'.
# Re.split() in python - hacker rank solution END
import re
print("\n".join(re.split(regex_pattern, input())))

Disclaimer: The above Problem (Re.split() in python) is generated by Hackerrank but the Solution is Provided by Chase2Learn. This tutorial is only for Educational and Learning purposes. Authority if any of the queries regarding this post or website fill the following contact form thank you.

Sharing Is Caring

Leave a Comment