Friday, February 1, 2019

Alternative Game

  • Problem Description

    Write a Python program to remove the alternate characters in the entered string.

    Refer sample input and output for formatting specification.

    All float values are displayed correct to 2 decimal places.

    All text in bold corresponds to input and the rest corresponds to output.
  • CODING ARENA
  • def modify(string):  
      final = ""   
      for i in range(len(string)):  
        if i % 2 == 0:  
          final = final + string[i]  
      return final
    string=input()
    print(modify(string))
  • Test Case 1

    Input (stdin)
    Remove alternate characters
    
    
    Expected Output
    Rmv lent hrces
  • Test Case 2

    Input (stdin)
    abcdefghij
    
    
    Expected Output
    acegi

No comments:

Post a Comment