Friday, February 1, 2019

Swap Letters

  • Problem Description

    Write a program to implement the following string operations.
    Input:
    You are given two strings, s1 and s2, separated by a new line. Each string will consist of lower case Latin characters ('a'-'z').
    Output:
    In the first line, print two space-separated integers, representing the length of s1 and s2 respectively. 
    In the second line, print the string produced by concatenating and (). 
    In the third line print, two strings separated by a space, s1 and s2. s1and s2are the same as s1 and s2, respectively, except that their first characters are swapped.
  • CODING ARENA
  • a=input()
    b=input()
    print(len(a),len(b))
    print(a+b)
    c=b[0]+a[1::]
    d=a[0]+b[1::]
    print(c,d)
  • Test Case 1

    Input (stdin)
    abcd
    
    ef
    
    
    Expected Output
    4 2
    
    abcdef
    
    ebcd af
  • Test Case 2

    Input (stdin)
    welcome
    
    tamilnadu
    
    
    Expected Output
    7 9
    
    welcometamilnadu
    
    telcome wamilnadu

No comments:

Post a Comment