Aim :
To replace the given string using the alternative string using python
Source Code:
stringvariable=raw_input("Enter a string :")
stringvariable=stringvariable.replace("a", "@")
stringvariable=string.replace("A", "@")
print("After Replace:")
print(stringvariable)
Output:
Enter a string: Orange
After Replace:
Or@nge
Explanation :
- The replace function replaces all occurrences of "a" and "A" to "@" and store it back in the variable
Also Seen :
Thanks and regards,
Google Bird
Comments