'count the files in directory and loop one by one

I have some different format files in a one directory, but i want to read only .txt file and print the based on the count ,

Example: (one.txt,two.txt,three.txt,four.txt,one.xlsx,two.xlsx)

here i want to count the .txt files and read all .txt file one by one , here the count is 4

read file one.txt

print("hello")

read file two.txt

print("hello")

read file three.txt

print("hello")

read file four.txt

print("hello")



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source