Latest questions in Python

0 votes
1 answer

How to find the occurrences of any word with more than two vowels in a file using regex?

for word in read: <--- iterating ...READ MORE

Nov 25, 2020 in Python by Gitika
• 65,910 points
2,432 views
0 votes
1 answer

How to merge multiple json objects into a single json object using python

You may do like this but it ...READ MORE

Nov 22, 2020 in Python by Gitika
• 65,910 points
18,693 views
0 votes
1 answer

Python and pip, list all versions of a package that's available?

The script at Pastebin does work. However, ...READ MORE

Nov 22, 2020 in Python by Gitika
• 65,910 points
5,025 views
0 votes
1 answer

Installing specific package versions with pip

TL;DR: pip install -Iv (i.e. pip install -Iv MySQL_python==1.2.2) First, I ...READ MORE

Nov 22, 2020 in Python by Gitika
• 65,910 points
745 views
0 votes
1 answer

How can I install pip on Windows?

Python 2.7.9+ and 3.4+ Python 3.4 (released March 2014) ...READ MORE

Nov 22, 2020 in Python by Gitika
• 65,910 points
440 views
0 votes
1 answer

Python Error: ModuleNotFoundError: No module named '<moduleName>'

Python3 and pip are most likely pointing ...READ MORE

Nov 22, 2020 in Python by Gitika
• 65,910 points
6,537 views
0 votes
1 answer

I am not able to install pywin32 into my Macos ..I tried all the ways and I could not fix the error...can you please help me

Hello @Harikrishna, For your query you can refer ...READ MORE

Nov 23, 2020 in Python by Niroj
• 82,880 points
5,829 views
0 votes
1 answer

invalid literal for int() with base 10 in python

Hello, You can try this simple code: def getSum(n): ...READ MORE

Nov 23, 2020 in Python by Niroj
• 82,880 points
1,886 views
0 votes
1 answer

I've been trying to run this code, but the error says "Expected an indented block" for the line, " word_as_list[index] = guess."

Hi, @Paradox, The error message IndentationError: expected an indented ...READ MORE

Nov 21, 2020 in Python by anonymous
• 65,910 points
865 views
0 votes
1 answer

How to Install pip for python 3.7 on Ubuntu 18?

The command you're looking for is: python3.7 -m ...READ MORE

Nov 20, 2020 in Python by Gitika
• 65,910 points
8,979 views
0 votes
1 answer

How are Python metaclasses different from regular class inheritance?

Python 3 class MyClass(object): = New-style class class MyClass: = New-style ...READ MORE

Nov 20, 2020 in Python by Gitika
• 65,910 points
309 views
0 votes
1 answer

How to get the current time in Python?

Use: >>> import datetime >>> datetime.datetime.now() datetime.datetime(2009, 1, 6, 15, ...READ MORE

Nov 20, 2020 in Python by Gitika
• 65,910 points
450 views
0 votes
1 answer

How do I parse XML in Python?

First build an Element instance root from the XML, ...READ MORE

Nov 20, 2020 in Python by Gitika
• 65,910 points
614 views
0 votes
1 answer

How do I install a Python package with a .whl file?

I just used the following which was ...READ MORE

Nov 20, 2020 in Python by Gitika
• 65,910 points
4,826 views
0 votes
1 answer

How to create a zip archive of a directory in Python?

Hii, The easiest way is to use shutil.make_archive. It ...READ MORE

Nov 20, 2020 in Python by Niroj
• 82,880 points
645 views
0 votes
1 answer

How do I update pip itself from inside my virtual environment?

Hello, pip is just a PyPI package like any other; you ...READ MORE

Nov 20, 2020 in Python by Niroj
• 82,880 points
4,724 views
0 votes
1 answer

ImportError: No module named requests

Hello, To install requests module for Python2: $ sudo apt-get install ...READ MORE

Nov 20, 2020 in Python by Niroj
• 82,880 points
670 views
0 votes
1 answer

How can I open multiple files using “with open” in Python?

Hello, Just replace and with , and you're done: try: ...READ MORE

Nov 20, 2020 in Python by Niroj
• 82,880 points
1,304 views
0 votes
1 answer

How to set environment variables in Python?

Hii, Environment variables must be strings, so use os.environ["DEBUSSY"] ...READ MORE

Nov 20, 2020 in Python by Niroj
• 82,880 points
649 views
0 votes
1 answer

Why not inherit from List<T>?

There are some good answers here. I ...READ MORE

Nov 20, 2020 in Python by Gitika
• 65,910 points
349 views
0 votes
4 answers

How to print instances of a class using print()?

You need to implement your own __repr__ ...READ MORE

Nov 25, 2020 in Python by Saksham Azad
966 views
0 votes
2 answers

How can I safely create a nested directory?

No need to put filename.txt For directory check path ...READ MORE

Nov 25, 2020 in Python by Deepak Chaurasia
1,371 views
0 votes
1 answer

How to run code when a class is subclassed?

Classes (by default) are instances of the ...READ MORE

Nov 20, 2020 in Python by Gitika
• 65,910 points
378 views
0 votes
0 answers

Which python projects are good for beginner If I already know the basics very well?

Which python projects are good for beginner ...READ MORE

Nov 19, 2020 in Python by samar
• 120 points
264 views
0 votes
1 answer

I have created python chatbot using flask framework using yml file now i want to use json file what should i do now ?

Hello @golu , Try something like this: with open(yaml_file, 'r') ...READ MORE

Nov 19, 2020 in Python by Niroj
• 82,880 points
1,409 views
0 votes
1 answer

How to get the home directory in Python?

Hello, You need to use os.path.expanduser. This will ensure it works ...READ MORE

Nov 19, 2020 in Python by Niroj
• 82,880 points
1,478 views
0 votes
1 answer

How do I parse XML in Python?

Hello @kartik, You can use BeautifulSoup: from bs4 import BeautifulSoup x="""<foo> ...READ MORE

Nov 19, 2020 in Python by Niroj
• 82,880 points
317 views
0 votes
1 answer

How do I create a constant in Python?

Hello @kartik, No there is not. You cannot ...READ MORE

Nov 19, 2020 in Python by Niroj
• 82,880 points
1,200 views
0 votes
1 answer

How can I safely create a nested directory?

Python 3.5+: import pathlib pathlib.Path('/my/directory').mkdir(parents=True, exist_ok=True) pathlib.Path.mkdir as used above ...READ MORE

Nov 19, 2020 in Python by Gitika
• 65,910 points
2,733 views
0 votes
1 answer

How to call an external command?

Look at the subprocess module in the standard library: import ...READ MORE

Nov 19, 2020 in Python by Gitika
• 65,910 points
373 views
0 votes
1 answer

Speed up millions of regex replacements in Python 3

One thing you can try is to ...READ MORE

Nov 19, 2020 in Python by Gitika
• 65,910 points
1,522 views
0 votes
1 answer

How to use multiprocessing pool.map with multiple arguments?

The answer to this is version- and ...READ MORE

Nov 19, 2020 in Python by Gitika
• 65,910 points
13,755 views
0 votes
1 answer

How do I get the number of elements in a list?

Hello, The len() function can be used with several different ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,880 points
452 views
0 votes
1 answer

How to access environment variable values?

Hello @kartik, To check if the key exists ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,880 points
297 views
0 votes
1 answer

How do I pass a variable by reference?

Hello, Just wrap it in a list: def Change(self, ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,880 points
321 views
0 votes
1 answer

How do I list all files of a directory?

Hii, Try this: import os os.listdir("somedirectory") Thank you!! ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,880 points
348 views
0 votes
1 answer

Error:AttributeError: 'NoneType' object has no attribute 'extend'

Hello @kartik, You can use itertools.chain(): import itertools list2d = [[1,2,3], ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,880 points
3,033 views
0 votes
1 answer

How can I create a nested directory?

Hello, Using try except and the right error ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,880 points
355 views
0 votes
1 answer

How to call an external command?

Hello @kartik, Look at the subprocess module in the standard ...READ MORE

Nov 18, 2020 in Python by Niroj
• 82,880 points
339 views
0 votes
1 answer

How to generate all permutations of a list?

Hello @kartik, Try this: def permutations(head, tail=''): ...READ MORE

Nov 17, 2020 in Python by Niroj
• 82,880 points
684 views
0 votes
1 answer

How to concatenate items in a list to a single string?

Hello @kartik, Use join: >>> sentence = ['this','is','a','sentence'] >>> '-'.join(sentence) 'this-is-a-sentence' Hope it ...READ MORE

Nov 17, 2020 in Python by Niroj
• 82,880 points
468 views
0 votes
1 answer

How to test multiple variables against a value?

Hello @kartik, Your problem is more easily addressed ...READ MORE

Nov 17, 2020 in Python by Niroj
• 82,880 points
372 views
0 votes
1 answer

How can I do not equal in Django queryset filtering?

Hello @kartik, You can use Q objects for this. They ...READ MORE

Nov 17, 2020 in Python by Niroj
• 82,880 points
517 views
0 votes
1 answer

Which is the best Python web framework for beginners?

Go for Django . It's easy and ...READ MORE

Nov 18, 2020 in Python by Jayant Kumar
570 views
0 votes
1 answer

Creating a login page, when passing json values showing me error?<class 'NoneType'>???

#appriciate your helping email = input("enter your email ...READ MORE

Nov 17, 2020 in Python by rehan
• 160 points
1,074 views
0 votes
0 answers

How can I solve it? TypeError: unsupported operand type(s) for /: 'float' and 'list'

I am trying to calculate numerical integration ...READ MORE

Nov 17, 2020 in Python by asimsek
• 120 points
13,137 views
0 votes
1 answer

How to generate a string token using four of this items random?

One approach just generates random integers up ...READ MORE

Nov 16, 2020 in Python by Gitika
• 65,910 points
474 views
0 votes
1 answer

Sigma code look like this but it’s not working.

Use Markdown to style code: - Use a ...READ MORE

Nov 15, 2020 in Python by Gitika
• 65,910 points
435 views
0 votes
1 answer

The below code prints none at the end.

the code after return does not execute. ...READ MORE

Nov 15, 2020 in Python by Gitika
• 65,910 points
384 views