Write a Python program to get a string from a given string where all occurrences of its first char have been changed to "@", except the first char itself


This program is written in the Python programming language and it manipulates a given string in two steps:

  • The first step is to assign the first character of the string "tutor joes" to a variable named "ch".
  • In the second step, the program replaces the first character of the string with the symbol "@". It then concatenates the original first character stored in the "ch" variable back to the rest of the string. The result of this operation is a new string "@utor joes".

Finally, the program prints both the original string "tutor joes" and the modified string "@utor joes" to the console.

Source Code

str="tutor joes"
print("Given String :",str)
ch = str[0]
str = str.replace(ch, '@')
str = ch + str[1:]
print("After String :",str)

Output

Given String : tutor joes
After String : tu@or joes


Example Programs