Find the question in attachment
Attachments:
Answers
Answered by
5
The given problem is solved using language - Python.
n=input('Enter address: ')
num=''
for i in n:
if i.isdigit():
num+=i
print(num)
---- OR ----
n=input('Enter address: ')
num=''.join(i for i in n if i.isdigit())
print(num)
- The isdigit() function checks whether all the characters present in a string is a digit or not.
- Here, we are accessing all the characters in the string using a loop. Inside the loop, we are checking if the characters are digits or not. If true, the numbers are concatenated. In this way, we can display the pincode of the address.
See attachment for output.
Attachments:
Answered by
2
Or if the format of the address is always given: NSB ROAD, DURGAPUR, 713204, then this approach will also work:
print(input("Address: ").split(",")[-1].replace(" ", ""))
Similar questions