Q. A text file contains alphanumeric text (say an.txt). Write a program that reads this text file and prints only the numbers or digits from the file.


Answer =


F = open("an.txt", "r")
for line in F :
  words = line.split()
  for i in words :
    for letter in i :
      if(letter. isdigit()) :
        print(letter)

1 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )


  1. F = open("an.txt", "r")
    for line in F :
    words = line.split()
    for i in words :
    for letter in i :
    if(letter. isdigit()) :
    print(letter)

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post