Replace Characters

Easy Strings
Solve in Playground →

Problem Statement

Write a Python program to replace all occurrences of a specific character with another character in a string.

Input Format

Line 1: Original string. Line 2: Character to replace and replacement character separated by space.

Output Format

Print the modified string.

Constraints

Single characters specified

Sample Input

hello world
o a

Sample Output

hella warld

Explanation

Use the string `.replace()` method.

Starter Code

def replace_chars(s, old_char, new_char):
    # Write your code here
    pass

s = input()
old_char, new_char = input().split()
print(replace_chars(s, old_char, new_char))

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used