Wednesday, November 27, 2019

Re.split() - Hacker Rank Solution

Check Tutorial tab to know how to to solve.
You are given a string  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 .

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

Re.split() - Hacker Rank Solution

We want to split the string on every occurrence of a dot and on every occurrence of a comma, so an example pattern can be [.,].

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

2 comments:

  1. regex_pattern = r"[,.]" # Do not delete 'r'.
    import re
    print("\n".join(re.split(regex_pattern, input())))

    ReplyDelete
    Replies
    1. def is_leap(year):
      if year %4==0:
      if year%100==0:

      if year%400!=0:
      return "False"
      return 'True'
      if year%4!=0:
      return 'False'
      if year%100==0:
      return "False"
      if year%400!=0:

      return 'False'



      year = int(input())
      print(is_leap(year))

      Delete

Powered by Blogger.