Tuesday, 10 March 2020

Python to get only digits from a file and append into a list



            f = open('file2.txt', 'r')
            for line in f:
                    words = line.split()
                    for i in words:
                            if(i.isdigit()):
                                mylist.append(i)
            print (mylist)

No comments:

Post a Comment

Git

1 git add ↳ It lets you add changes from the working directory into the staging area 2 git commit ↳ It lets you save a snapshot of currently...