Back

string 

Created 2 years ago
773 Views
2 Comments
Santoshuske
@Santoshuske
Santoshuske
@SantoshuskeProfile is locked. Login

Given a string and a number K, change every kth character to uppercase from beginning in string.
Sample Testcase :
INPUT
string 2
OUTPUT
sTrInG

plz help me to slove this i got correct output in colab but test cases fails

k=input().split()
x=k[0]
y=int(k[1])
z=[]
for i in range (y-1,len(x),y):
  if i:
    z.append(x[i-1]+x[i].upper())
  else:
    z.append(x[i])

print("".join(z))
Comments (2)
Please login to comment.