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,198 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
983 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
801 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
805 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,519 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
526 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
479 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
626 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
494 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
749 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
566 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,461 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
399 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
681 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,825 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,663 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
660 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
715 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,633 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
681 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
670 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 618 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,431 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
519 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,023 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,444 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,106 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
890 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,167 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,591 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,924 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
563 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,627 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
831 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
552 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,977 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
544 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
801 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,146 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,263 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
532 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
800 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
528 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,881 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,881 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
591 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,474 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
670 views
0 votes
1 answer

How do you use a variable in a regular expression?

Instead of using the /regex/g syntax, you can construct ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,770 points
483 views