GUVI
Back

Test case Error in String

Created 2 years ago
65 Views
2 Comments
GokilaE
@GokilaE
GokilaE
@GokilaEProfile is locked. Login

Given a string S, print it after changing the middle element to (if the length of the string is even, change the 2 middle elements to ).

Sample Testcase :

INPUT

hello

OUTPUT

he*lo

S = input()
d = len(S)//2
if len(S)%2 == 1:
    print(S[0:d]+'*'+S[d+1:])
else:
    print(S[0:d-1]+'*'+S[d+1:])

I am getting private test case1 pass but private test case2 failed I didn't get correct output. Anyone can explain it.

Comments (2)
Please login to comment.
 
Powered by habitate.io Habitate