Sign change
Problem to change the sign in given string. The sign "+ or -" only.
Example-1:
Input : S = "+21--" Output : -21++
Example-2:
Input : S = "21" Output : 21
Solution
n = "+21--" d = "" for x in n: if(x=="+"): d += "-" elif(x == "-"): d += "+" else: d += x print(d)
Output
-21++