fork download
  1. # your code goes here
  2.  
  3. import re
  4.  
  5. def Rep(str,chr,Rchr):
  6. if chr in str:
  7. str1 = Rchr if chr else None
  8. result = re.sub(chr, str1, str)
  9. print(result)
  10. else:
  11. print("character is not present in the string to replace")
  12.  
  13. Rep("Hihwru","wr","oware")
Success #stdin #stdout 0.01s 7692KB
stdin
Standard input is empty
stdout
Hihowareu