Find all files in a directory with extension .txt in Python
Can someone tell me how to find all the files in directory with .txt extension in Python?
1 Answer · 701 Views · Answered ✓
Browse 802 Python questions and answers from learners and industry experts. Find practical fixes, interview prep and step-by-step solutions - or ask your own.
Can someone tell me how to find all the files in directory with .txt extension in Python?
1 Answer · 701 Views · Answered ✓
I installed both Python 2.7 and Python 2.6.5. I don't know what went wrong, but nothing related to Python seems to work any more. e.g. "setup.py…
1 Answer · 877 Views · Answered ✓
I have a method that sometimes returns a NoneType value. So how can I question a variable that is a NoneType? I need to use if method, for exampleif…
1 Answer · 714 Views · Answered ✓
I am trying to plot a histogram using the matplotlib.hist() function but I am not sure how to do it.I have a listprobability = [0.3602150537634409,…
1 Answer · 1.5K Views · Answered ✓
What is the most efficient way to rotate a list in python? Right now I have something like this:>>> def rotate(l, n): return l[n:] + l[:n]>>> l =…
1 Answer · 1.6K Views · Answered ✓
Let's say my string is 10 characters long.How do I remove the last character?If my string is "abcdefghij" (I do not want to replace the 'j'…
1 Answer · 1.1K Views · Answered ✓
The print used to be a statement in Python 2, but now it became a function that requires parenthesis in Python 3.Is there any way to suppress these…
1 Answer · 1.3K Views · Answered ✓
How do I delete a column from a DataFrame? I know this data is not reproducible as I have a CSV file and I am trying to build a pandas data frame to…
2 Answers · 4.6K Views · Answered ✓
I\'m making a small program for math (no particular reason, just kind of wanted to) and I ran into the error \"TypeError: \'NoneType\' object is not…
1 Answer · 965 Views · Answered ✓
I am using code: def front_back(a, b): # +++your code here+++ if len(a) % 2 == 0 && len(b) % 2 == 0: return a[:(len(a)/2)] + b[:(len(b)/2)] +…
1 Answer · 769 Views · Answered ✓
I have a list in Python e.g.letters = ["t", "h", "e"]I want to print the array in a single line without the normal " []names = ["t", "h", "e"]print…
1 Answer · 1.3K Views · Answered ✓
I have a REST service built in node.js with Restify and Mongoose and a mongoDB with a collection with about 30.000 regular sized documents. I have my…
1 Answer · 1.3K Views · Answered ✓
Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Most-read guides across JanBask
Common Python interview questions, answered
Guides, tips and career advice on Python from JanBask experts.
Python How to Become a Python Developer: A Step-by-Step Guide for Beginners
Discover how to become a Python Developer via a practical 7-step guide build projects, maintain clean code, practice daily, and…
Python PCEP Certification Guide: Entry-Level Python Programmer Certification
Explore this PCEP certification guide for insights on cost, exam format, passing score, application, training, and study tips.…
Python Top 50+ Python Projects ideas for Beginners to Advanced
Discover innovative Python project ideas, explore advanced Python projects, and find good Python projects for beginners and…
Python How To Comment Out Multiple Lines In Python Like A Pro
Commenting out code is a common practice among programmers. It allows you to temporarily disable parts of your code without…
Pick another topic to find answers, interview questions, and real-world tips.