Computer Science, asked by ridsf356, 8 hours ago

Find the question in attachment​

Attachments:

Answers

Answered by anindyaadhikari13
5

\textsf{\large{\underline{Solution}:}}

The given problem is solved using language - Python.

n=input('Enter a‎ddress: ')

num=''

for i in n:

   if i‎.‎isdigit():

       num+=i

print(num)

---- OR ----

n=input('Enter a‎ddress: ')

num=''.join(i for i in n if i‎.‎isdigit())

print(num)

\textsf{\large{\underline{Explanation}:}}

  1. The isdigit() function checks whether all the characters present in a string is a digit or not.
  2. 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 p‎incod‎e of the ad‎dress.

See attachment for output.

Attachments:
Answered by atrs7391
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