Trending questions in Python

0 votes
1 answer

Python TypeError: 'list' object is not callable.

The error says the list is not ...READ MORE

Feb 9, 2019 in Python by Omkar
• 69,220 points
29,202 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,770 points
988 views
0 votes
1 answer

How to compare two string with some characters only in python?

You could use in to check if a string ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,770 points
806 views
0 votes
0 answers

How to create Personalised QR code using Python?

How to read and generate QR codes ...READ MORE

Nov 27, 2020 in Python by kartik
• 37,520 points
806 views
0 votes
1 answer

ModuleNotFoundError: No module named 'pytest'

Hi@akhtar, You need to install pytest module in ...READ MORE

Jun 24, 2020 in Python by MD
• 95,460 points
7,523 views
0 votes
1 answer

Static methods in Python?

Yep, using the static method decorator class MyClass(object): ...READ MORE

Dec 2, 2020 in Python by Gitika
• 65,770 points
531 views
0 votes
1 answer

Getting the last element of a list

some_list[-1] is the shortest and most Pythonic. In fact, ...READ MORE

Dec 3, 2020 in Python by anonymous
• 65,770 points
481 views
0 votes
1 answer

can someone please help me with python?

Hello @ Anee, Code: num1 = int(input("Enter First Number: ")) num2 ...READ MORE

Nov 30, 2020 in Python by Niroj
• 82,840 points
628 views
0 votes
1 answer

How to determine a Python variable's type?

Use the type() builtin function: >>> i = 123 >>> type(i) <type ...READ MORE

Dec 2, 2020 in Python by Gitika
• 65,770 points
497 views
0 votes
1 answer

How do I check if a given Python string is a substring of another one?

Try using in like this: >>> x = 'hello' >>> y ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,770 points
756 views
0 votes
1 answer

Are static class variables possible in Python?

Variables declared inside the class definition, but ...READ MORE

Nov 30, 2020 in Python by Gitika
• 65,770 points
573 views
0 votes
1 answer

pytest: error: unrecognized arguments: --html=basic.html

Hi@akhtar, You have to install one module named ...READ MORE

Jun 24, 2020 in Python by MD
• 95,460 points
7,464 views
0 votes
0 answers

I need id by objects

Hello geeks: Here is my models:    class Room_Type(models.Model): """Django data ...READ MORE

Dec 5, 2020 in Python by Mohamed
• 170 points
401 views
0 votes
1 answer

What is the Python 3 equivalent of “python -m SimpleHTTPServer”

The SimpleHTTPServer module has been merged into http.server in Python 3.0. ...READ MORE

Nov 28, 2020 in Python by Gitika
• 65,770 points
686 views
0 votes
1 answer

Error:UnicodeDecodeError when reading CSV file in Pandas with Python

Hello @kartik, Try this: import pandas as pd df = ...READ MORE

Jun 15, 2020 in Python by Niroj
• 82,840 points
7,831 views
0 votes
1 answer

You have to print the cheapest item using the dictionary key and values

take input here import ast items=ast.literal_eval(input()) #start writing your code ...READ MORE

Dec 19, 2020 in Python by anonymous
3,666 views
0 votes
1 answer

Extracting extension from filename in Python

Yes. Use os.path.splitext >>> import os >>> filename, file_extension = ...READ MORE

Nov 27, 2020 in Python by Gitika
• 65,770 points
662 views
0 votes
1 answer

How can I list txt files into the folder?

Hello @Mziko You can refer this:https://datatofish.com/txt-files-d ...READ MORE

Nov 26, 2020 in Python by Niroj
• 82,840 points
718 views
0 votes
0 answers

ValueError: could not broadcast input array from shape (224,224,9) into shape (224,224)

img_shape = 224 test_data = [] test_labels = [] for ...READ MORE

Nov 6, 2020 in Python by Eyosiyas
• 120 points
1,637 views
0 votes
1 answer

How to print without newline or space?

In Python 3, you can use the sep= and end= parameters ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,770 points
682 views
0 votes
1 answer

How to Test a string for a substring?

if "ABCD" in "xxxxABCDyyyy": ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,770 points
676 views
0 votes
0 answers

Why I'm Getting ValueError?

Here is my code: import pandas as p import ...READ MORE

Nov 28, 2020 in Python by Rohan
• 200 points

edited Nov 30, 2020 by Niroj 622 views
0 votes
1 answer

AttributeError: 'NoneType' object has no attribute 'find'

Hi@akhtar, It seems Sklearn is not installed properly ...READ MORE

Jun 23, 2020 in Python by MD
• 95,460 points
7,435 views
0 votes
1 answer

Error "Failed to load tensorflow runtime"

Hello, Try to downgrade protobuf, this worked for ...READ MORE

Nov 30, 2020 in Python by Niroj
• 82,840 points
521 views
0 votes
1 answer

How to print only the line which starts with P?

Hi, you might have found another way ...READ MORE

Dec 2, 2020 in Python by Tyler
• 140 points
1,025 views
0 votes
1 answer

How can I generating file to download with Django?

Hello @kartik, To trigger a download you need ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,840 points
5,448 views
0 votes
1 answer

How to enter this command “py -3 -m pip install -r requirements.txt”

Open cmd and type the command and ...READ MORE

Nov 15, 2020 in Python by Gitika
• 65,770 points
1,108 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,840 points
891 views
0 votes
1 answer

How to read an excel file (name User defined) from a path using python?

Hi @There, As the path is fixed, use ...READ MORE

Aug 13, 2020 in Python by Gitika
• 65,770 points
5,173 views
0 votes
1 answer

How to show Image from Imagefield Django Admin ?

Hello @kartik, In your model class add a ...READ MORE

Aug 3, 2020 in Python by Niroj
• 82,840 points
5,592 views
0 votes
1 answer

Error:Unresolved reference 'django' error in PyCharm

Hello @kartik, I assume you're using a virtualenv ...READ MORE

Jul 2, 2020 in Python by Niroj
• 82,840 points
6,926 views
0 votes
0 answers

TypeError: tuple indices must be integers or slices, not tuple

Traceback (most recent call last):   File "main.py", line ...READ MORE

Aug 25, 2020 in Python by Peddabudi srikanth
• 120 points
4,631 views
0 votes
1 answer

Does array element contain substring?

Loop through the $forbiddennames array and use stripos to check if ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,770 points
566 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,840 points
835 views
0 votes
1 answer

AttributeError: module 'http' has no attribute 'client

Hi@akhtar, To avoid this error make sure you ...READ MORE

Apr 22, 2020 in Python by MD
• 95,460 points
9,982 views
0 votes
1 answer

How to determine whether a substring is in a different string [duplicate]

with in: substring in string: >>> substring = "please help ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,770 points
553 views
0 votes
1 answer

How do I get a substring of a string in Python?

>>> x = "Hello World!" >>> x[2:] 'llo World!' >>> ...READ MORE

Nov 27, 2020 in Python by Gitika
• 65,770 points
546 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,770 points
804 views
0 votes
1 answer

How to insert value by one post method in 2 table with Django?

try  import-export   library of Django or if you are ...READ MORE

Nov 12, 2020 in Python by Gitika
• 65,770 points
1,147 views
0 votes
1 answer

How to convert bytes to a string?

You need to decode the bytes object ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,770 points
535 views
0 votes
1 answer

Help please on basic python web server

Hi, @There, The error is because there is ...READ MORE

Oct 27, 2020 in Python by Gitika
• 65,770 points
1,886 views
0 votes
0 answers

NameError: name 'genomic_dna_4' is not defined

I use python for biology and I got ...READ MORE

Nov 10, 2020 in Python by skylar
• 120 points
1,264 views
0 votes
1 answer

Test Failed: unsupported operand type(s) for -: 'tuple' and 'list'

Hi, @There, Check what are you passing.. the ...READ MORE

Oct 5, 2020 in Python by Gitika
• 65,770 points
2,884 views
0 votes
1 answer

How can I get a list of locally installed Python modules?

Do not use with pip > 10.0! My ...READ MORE

Nov 26, 2020 in Python by anonymous
• 65,770 points
530 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,840 points
801 views
0 votes
1 answer

Calling a function of a module by using its name (a string).

Assuming module foo with method bar: import foo method_to_call = getattr(foo, 'bar') result ...READ MORE

Nov 25, 2020 in Python by Gitika
• 65,770 points
594 views
0 votes
1 answer

Does Python have a string 'contains' substring method?

You can use the in operator: if "blah" not in ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,770 points
513 views
0 votes
1 answer

How to dynamically compose an OR query filter in Django?

Hello @kartik, You could chain your queries as ...READ MORE

Aug 3, 2020 in Python by Niroj
• 82,840 points
5,478 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,770 points
675 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,840 points
877 views