Algorithm


Problem Name: Python - Re.split()

Problem Link: hhttps://www.hackerrank.com/challenges/re-split/problem?isFullScreen=true

In this HackerRank Functions in PYTHON problem solution,

Check Tutorial tab to know how to to solve.

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

is preceeded and followed by a digit.

Sample Input 0

100,000,000.000

Sample Output 0

100
000
000
000

 

Code Examples

#1 Code Example with Python Programming

Code - Python Programming


regex_pattern = r"[,.]"	# Do not delete 'r'.

import re
print("\n".join(re.split(regex_pattern, input())))
Copy The Code & Try With Live Editor
Advertisements

Demonstration


Previous
[Solved] Map and Lambda Function in PYTHON solution in Hackerrank
Next
[Solved] Group(), Groups() & Groupdict() in PYTHON solution in Hackerrank