write a python program to input a number n and form a number by incrementing each digit by 1. The digit 9 should be replaced with 0.
For example:
If the original number is 129, the new number should be 230.
Answers
Answered by
0
Answer:
a = str(input("ENTER: "))
L = []
for i in a:
num = int(i)
num += 1
if num > 9:
num = 0
L.append(num)
else:
L.append(num)
print (int(''.join(str(i) for i in L)))
Answered by
0
Answer:
This is the required program for the question in Python 3.
n=int(input("Enter a number: "))
m=0
for letter in str(n):
x=int(letter)
x+=1
if x==10:
x=0
m=m*10+x
print("Modified Number: ",m)
Algorithm:
- START.
- Accept the number.
- Initialise m=0
- Convert the number into string.
- Get the letters of the string from first to last.
- Convert each letter to number and add 1 to it.
- If the result becomes greater than 9, change it's value to 0.
- Multiply m by 10 and add the result to it.
- Display the value of m at last.
- STOP.
See the attachment for output ☑.
Attachments:
Similar questions