Search This Blog

NewLine and Tab Spacing -Python HackerRank Questions and answers -- Course ID: 55193

Newline and Tab Spacing & Raw String 

Write the function definition for the function 'Escape', which takes 3 parameters s1, s2, s3, all of which are STRING variables.

Assign "Python\tRaw\nString\tConcept" to a STRING Variable 's'.

The expected output is as follows:

1. Print these 3 strings separated by New Line

2. Print these 3 strings separated by a Tab Space

3. Print 's'

4. Print the Raw String of 's'

Input Format for Custom Testing

#In the first line, value for 's1'

#In the second line, value for 's2'

#In the third line, value for 's3 

Sample Test Case 1

Sample Input

STDIN        Function parameter
-----        ------------------
Bahubali →   s1
is a     →   s2
Legend   →   s3  
Sample Output
Bahubali
is a
Legend
Bahubali    is a    Legend
Python    Raw
String    Concept
Python\tRaw\nString\tConcept
Answer:
#!/bin/python3

import math
import os
import random
import re
import sys


#
# Complete the 'Escape' function below.
#
# The function accepts following parameters:
#  1. STRING s1
#  2. STRING s2
#  3. STRING s3
#

def Escape(s1, s2, s3):
    # Write your code here
    s = "Python\tRaw\nString\tConcept"
    print(f"{s1}\n{s2}\n{s3}")
    print(f"{s1}\t{s2}\t{s3}")
    print(s)
    print(r'Python\tRaw\nString\tConcept')

if __name__ == '__main__':
    s1 = input()

    s2 = input()

    s3 = input()

    Escape(s1, s2, s3)


Click on Image for detailed information:


4 comments:

  1. Hi Tech Freak,
    Thank you so much for your help
    I was indeed looking for this, tried lot of solution, my answers were matching but still I was not getting passed. Thanks for your solution.

    ReplyDelete
  2. Enjoyed examining this, very good stuff, appreciate it. you can try this out

    ReplyDelete

If you have any doubts, Please let us know.