Create a function called count_files. The function will accept a string that is in the format of 'glob pattern' (review the lectures for example). The function will then use glob to determine how many files match the pattern. The function will return the count of the number of files that match. For example, if 5 files match the pattern, the function will return 5.
Added by Jose Luis A.
Close
Step 1
Then, we will define the function count_files that takes a string as an argument. Inside the function, we will use the glob function from the glob module to get a list of files that match the pattern. The length of this list is the number of files that match the Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 80 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Write a complete program that asks the user to enter the name of a text file. Using a function, open and read the contents of the file and count how many lines exist in the text file. Display only the number of lines counted to the user. Do not display any message from the count_lines function. (Hint: ask yourself how lines are saved in a text file) Declare a function as below: int count_lines(string filename)
Liam H.
Write a function to find the count of all digits in a given number N. The number will be passed to the function as an input parameter of type int
Sarvesh S.
Aarya B.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD