Python String replace() MethodReturn a copy of the string with all occurrences of substring old replaced by new. If the optional argument count is given, only the first count occurrences are replaced. SignatureParametersold : An old string which will be replaced. new : New string which will replace the old string. count : The number of times to process the replace. ReturnIt returns string Let's see some examples of replace() method to understand it's functionality. Python String replace() Method Example 1Output: Old String: Java is a programming language New String: C is a programming language Python String replace() Method Example 2Output: Old String: Java C C# Java Php Python Java New String: C# C C# C# Php Python C# Old String: Java C C# Java Php Python Java New String: C# C C# Java Php Python Java Python String replace() Method Example 3Output: Tomato is also a fruit
Next TopicPython Strings
|
JavaTpoint offers too many high quality services. Mail us on [email protected], to get more information about given services.
JavaTpoint offers college campus training on Core Java, Advance Java, .Net, Android, Hadoop, PHP, Web Technology and Python. Please mail your requirement at [email protected]
Duration: 1 week to 2 week