Trending questions in Python

0 votes
1 answer

I am making a ai in python but there is a error

Hi, @Rhydham, Try this: engine = pyttsx3.init('dummy') If you want ...READ MORE

Oct 12, 2020 in Python by Gitika
• 65,910 points

edited Aug 11, 2021 by Soumya 2,934 views
0 votes
1 answer

Python: “TypeError: Object type <class 'str'> cannot be passed to C code”

You have to pass byte string as ...READ MORE

Aug 20, 2019 in Python by Jishan
20,970 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
957 views
0 votes
1 answer

How do I detect whether a Python variable is a function?

Hello @kartik, You can import isfunction from the inspect module. >>> from inspect ...READ MORE

Dec 7, 2020 in Python by Niroj
• 82,880 points
436 views
0 votes
1 answer

What is the difference between an abstract function and a virtual function?

An abstract function cannot have functionality. You're basically ...READ MORE

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

How to check if type of a variable is string?

Hello @kartik, You can do: var = 1 if type(var) ...READ MORE

Dec 7, 2020 in Python by Niroj
• 82,880 points
414 views
0 votes
1 answer

Importing modules from parent folder

It seems that the problem is not ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,910 points
883 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,195 views
0 votes
1 answer

Error is "invalid literal for int() with base 10: ' ' "

This error is caused because we try ...READ MORE

Oct 15, 2020 in Python by Gitika
• 65,910 points
2,692 views
0 votes
1 answer

There are some Error so resolve quickly

Hi@Aditya, It is working fine in my python ...READ MORE

Dec 9, 2020 in Python by MD
• 95,440 points
337 views
0 votes
1 answer

When i try to install os_sys i get an error when installing backend dependencies

pip install -U os-sys READ MORE

Oct 16, 2020 in Python by anonymous
3,192 views
0 votes
1 answer

What is the easiest way to remove all packages installed by pip?

I've found this snippet as an alternative ...READ MORE

Dec 4, 2020 in Python by Gitika
• 65,910 points
501 views
0 votes
0 answers

convert dictionary in python

can you please help me on this. ...READ MORE

Dec 10, 2020 in Python by Edureka
• 120 points
288 views
0 votes
1 answer

How do I copy a file in Python?

from shutil import copyfile copyfile(src, dst) Copy the contents ...READ MORE

Dec 7, 2020 in Python by Gitika
• 65,910 points
384 views
0 votes
1 answer

How do I check if a string is a number (float)?

I'm not sure that anything much could ...READ MORE

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

i am getting an error on pycharm while installing packages

Hi, @There, $ pip install gevent --pre $ pip ...READ MORE

Oct 27, 2020 in Python by Gitika
• 65,910 points
2,136 views
0 votes
1 answer

ValueError: too many values to unpack (expected 3)

Hello @Alisha , Do print(func(x)) and find out what's ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,880 points
5,370 views
0 votes
1 answer

How do I copy a file in Python?

from shutil import copyfile copyfile(src, dst) Copy the ...READ MORE

Dec 7, 2020 in Python by Gitika
• 65,910 points
348 views
0 votes
1 answer

What is the difference between an interface and abstract class?

Interfaces An interface is a contract: The person writing ...READ MORE

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

Why is it string.join(list) instead of list.join(string)?

It's because any iterable can be joined ...READ MORE

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

How to import a module given its name as string?

With Python older than 2.7/3.1, that's pretty ...READ MORE

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

How to delete a file or folder?

os.remove() removes a file. os.rmdir() removes an empty directory. shutil.rmtree() deletes a ...READ MORE

Dec 7, 2020 in Python by Gitika
• 65,910 points
322 views
0 votes
1 answer

ModuleNotFoundError: No module named 'urllib'

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

Jun 26, 2020 in Python by MD
• 95,440 points
7,380 views
0 votes
1 answer

How to make function decorators and chain them together?

Here is what you asked for: from functools ...READ MORE

Dec 4, 2020 in Python by Gitika
• 65,910 points
418 views
0 votes
1 answer

How to randomly select an item from a list?

Use random.choice() import random foo = ['a', 'b', 'c', 'd', ...READ MORE

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

Difference between __str__ and __repr__?

The default implementation is useless (it’s hard ...READ MORE

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

IndentationError: expected an indented block

Hello @ nishit, Indentation means the space from margin to ...READ MORE

Aug 10, 2020 in Python by Niroj
• 82,880 points
5,478 views
0 votes
1 answer

How to convert doc file into pdf using python?

A simple example using com types, converting ...READ MORE

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

Webscraping error using your code

Hi, @Shrinidhi, Kindly share your code snippet with ...READ MORE

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

Could you please help to write a code for this program

Hello, @Hitesh, You can follow the below: print("List of ...READ MORE

Nov 4, 2020 in Python by Roshni
• 10,520 points
1,645 views
0 votes
1 answer

How to know if an object has an attribute in Python?

Try hasattr(): if hasattr(a, 'property'): a.property The ...READ MORE

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

Check if a given key already exists in a dictionary?

in is the intended way to test for ...READ MORE

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

my Py Audio is not Downloading what should I do

Hello @S.P.D, First try to check your python ...READ MORE

Nov 30, 2020 in Python by Niroj
• 82,880 points
537 views
0 votes
2 answers

How to convert integer to string in Python?

if You Want to convert int to ...READ MORE

Nov 28, 2020 in Python by Rohan
• 200 points
575 views
0 votes
1 answer

How to import an image into a csv file using python?

I am sure you are aware CSV ...READ MORE

Jun 25, 2020 in Python by Bhanu Kumar
7,333 views
0 votes
1 answer

How do I concatenate two lists in Python?

You can use the + operator to combine them: listone ...READ MORE

Dec 3, 2020 in Python by anonymous
• 65,910 points
368 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,068 views
0 votes
1 answer

Python error "TypeError: string indices must be integers, not str"

Hey @Dipti email_s.append(email_1["email_address"]) This is the list on ...READ MORE

Jul 5, 2019 in Python by Jinu
22,702 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,910 points
389 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
304 views
0 votes
1 answer

How to replace all occurrences of a string?

The general pattern is str.split(search).join(replacement) This used to be ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,910 points
638 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,910 points
328 views
0 votes
1 answer

Why does DEBUG=False setting make my django Static Files Access fail?

Hello @kartik, If you still need to server ...READ MORE

Aug 6, 2020 in Python by Niroj
• 82,880 points
5,466 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,510 points
628 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,880 points
479 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
860 views
0 votes
1 answer

How to find all occurrences of a substring?

There is no simple built-in string function ...READ MORE

Nov 25, 2020 in Python by Gitika
• 65,910 points
670 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,910 points
582 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,910 points
318 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
743 views