# Python program to replace all 0’s with 1 in a given integer
def re(n):
if (n == 0):
return 0;
# Extract the last digit and change it if needed
digit = n % 10
if (digit == 0):
digit = 1
return re(int(n/10)) * 10 + digit
n = int(input("Enter the number : "))
print("Number after replacement : ",re(n))
No comments:
Post a Comment