{"id":19046,"date":"2021-08-29T15:13:19","date_gmt":"2021-08-29T09:43:19","guid":{"rendered":"https:\/\/python-programs.com\/?p=19046"},"modified":"2021-11-22T18:37:09","modified_gmt":"2021-11-22T13:07:09","slug":"python-program-for-sign-change","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-for-sign-change\/","title":{"rendered":"Python Program for Sign Change"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Find the Previous Armstrong Number<\/a>
\nGiven a String and the task is to change the ‘+’ sign into ‘-‘ and vice versa for a given string.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given String = \"  --btech++geeks-- \"<\/pre>\n

Output:<\/strong><\/p>\n

The given string { --btech++geeks-- } after changing the '+' sign into '-' and vice versa = ++btech--geeks++<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given String = \"--1++2--3+\"<\/pre>\n

Output:<\/strong><\/p>\n

The given string { --1++2--3+ } after changing the '+' sign into '-' and vice versa = ++1--2++3-<\/pre>\n

Program for Sign Change in Python<\/h2>\n

Below are ways to change the ‘+’ sign into ‘-‘ and vice versa for a given string\u00a0 :<\/p>\n