aaaadaa

ABC 384

Problem 32 of 50

Easy

What to do

Given a string `s`, a character to keep `c1`, and a replacement character `c2`, replace every character in s that is NOT c1 with c2. Return the modified string. For example, s='atcoder', c1='d', c2='a' → 'aaaadaa'.

Key Concepts

string manipulation loops conditionals

Examples

Input: n = 3, c1 = 'b', c2 = 'g', s = 'abc'

Output: gbg

Input: n = 1, c1 = 's', c2 = 'h', s = 's'

Output: s

Tips for Beginners

  • Focus on understanding the logic, not memorizing syntax
  • Use print statements to debug your code
  • Don't worry about input parsing - the function handles that for you
  • If stuck, try writing out your solution on paper first

Python Editor

Loading Python...