You are given a string S of length N consisting of A, B and C, and an integer K which is…
- User
You are given a string S of length N consisting of
A,BandC, and an integer K which is between 1 and N (inclusive). Print the string S after lowercasing the K-th character in it.Constraints
- 1 ≤ N ≤ 50
- 1 ≤ K ≤ N
- S is a string of length N consisting of
A,BandC. Input
Input is given from Standard Input in the following format:
N K S
Output
Print the string S after lowercasing the K-th character in it.
Examples
Input
3 1 ABC
Output
aBC
Input
4 3 CABA
Output
CAbA
Assistant
We need to solve the problem: given N, K, and string S of length N consisting of uppercase letters A, B, C. We need to output S with the K-th character lowercased. (e.g., if it's 'A', output 'a'; 'B' -> 'b'; 'C' -> 'c'). The rest remain uppercase.
Constraints small, but simple solution.
We need to implement in a way that reads from stdin, processes, prints.
Potential pitfalls: indexing: K is 1-indexed, so we need to change S[K-1] to lowercase.
We can just convert the character to lowercase. In Python, we can use str.lower() for that char.
So code:
def solve(): import sys data = sys.stdin.read().split() N = int(data[0]) K = int(data[1]) S = data[2] # Ensure length correct. # Create new string: S[:K-1] + S[K-1].lower() + S[K:] result = S[:K-1] + S[K-1].lower() + S[K:] print(result)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.