Most viewed questions in Python

+2 votes
2 answers

What is the difference between print and return in python?

Return statements end the execution of a ...READ MORE

Aug 26, 2019 in Python by anonymous
7,493 views
0 votes
1 answer

What's the difference in Qt between setVisible, setShown and show/hide

show() is just a convenience function for ...READ MORE

Apr 17, 2018 in Python by anonymous
7,480 views
0 votes
1 answer

Python sort() function arguments

Both sort and sorted have three keyword arguments: cmp, key and reverse. L.sort(cmp=None, key=None, reverse=False) -- ...READ MORE

Oct 8, 2018 in Python by SDeb
• 13,300 points
7,464 views
0 votes
1 answer

ImportError: cannot import name user

Hello @kartik, You missed the models - and ...READ MORE

Aug 17, 2020 in Python by Niroj
• 82,880 points
7,454 views
+1 vote
1 answer

How to save a bitmap or vector graphics image after creating a drawing with python's turtle module.

This worked for me: from Tkinter import * from ...READ MORE

Jul 6, 2019 in Python by Kyraa
7,452 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,880 points
7,424 views
0 votes
1 answer

TypeError: 'Element' object is not subscriptable

Hey Bharti, You can get some idea from ...READ MORE

Feb 18, 2020 in Python by Gitika
• 65,910 points
7,410 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,394 views
0 votes
1 answer

TypeError: Expected Ptr<cv::UMat> for argument '%s' ''

src is the first argument to cv2.cvtColor. The error you ...READ MORE

Oct 15, 2020 in Python by anonymous
• 65,910 points
7,377 views
0 votes
1 answer

Add header row in pandas dataframe while printing

Refer to this code: import pandas as pd col_name=['Name', ...READ MORE

Jul 5, 2019 in Python by Suri
7,358 views
0 votes
0 answers

The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I couldn't figure out the problem. here my ...READ MORE

Dec 17, 2020 in Python by muammer
• 120 points
7,349 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,343 views
0 votes
1 answer

How to load a custom JS file in Django admin home?

Hello @kartik, You can override templates/admin/index.html and add the JavaScript ...READ MORE

May 14, 2020 in Python by Niroj
• 82,880 points
7,335 views
+1 vote
2 answers

Difference: abstract class and interface in Python

If abstract class contains only abstract methods ...READ MORE

Jun 21, 2019 in Python by anonymous
7,311 views
0 votes
1 answer

How to drop all tables from the database with manage.py CLI in Django?

Hello @kartik, Python you can write your own ...READ MORE

Aug 7, 2020 in Python by Niroj
• 82,880 points
7,292 views
0 votes
2 answers

In List of Dicts, find min() value of a common Dict field

lst = [{'price': 99, 'barcode': '2342355'}, {'price': ...READ MORE

Aug 31, 2018 in Python by Omkar
• 69,210 points
7,289 views
0 votes
1 answer

shows "name connection not defined"

Hi, @Imthiii, Try removing the bracket you have ...READ MORE

Sep 17, 2020 in Python by Rajiv
• 8,910 points
7,275 views
0 votes
1 answer

How to read numbers from file in Python?

Assuming you don't have extraneous whitespace: with open('file') ...READ MORE

Apr 16, 2019 in Python by SDeb
• 13,300 points
7,249 views
0 votes
0 answers

Python error "IndexError: list index out of range"

I am trying to execute the following ...READ MORE

Jun 17, 2019 in Python by Alok
7,225 views
0 votes
1 answer

Error: No module named psycopg2.extensions

Hello @kartik, The first thing to do is ...READ MORE

Aug 17, 2020 in Python by Niroj
• 82,880 points
7,207 views
+1 vote
0 answers

TypeError: only integer scalar arrays can be converted to a scalar index

import cv2 import numpy as np import matplotlib.pyplot as ...READ MORE

Dec 18, 2019 in Python by sandeep
• 130 points
7,194 views
0 votes
1 answer

Django: Display a custom error message for admin validation error

Hello @kartik, Without looking, it sounds like the ...READ MORE

Jun 12, 2020 in Python by Niroj
• 82,880 points
7,193 views
0 votes
1 answer

How to input optional arguments in python command line?

Please use this code. if len(sys.argv) == 2: first_log ...READ MORE

Jul 11, 2019 in Python by Suri
7,176 views
0 votes
1 answer

I am trying to install os-win on my python 3.8. But I end up with the following error:

I have the same issue and is ...READ MORE

Sep 6, 2020 in Python by anonymous
7,161 views
+1 vote
3 answers

While using pyttsx 3 , I am having the following ERROR, i have installed pypiwin32

Try this: pip uninstall pyttsx3 Then: pip install pyttsx3==2.71 READ MORE

Aug 12, 2020 in Python by Eghosa
7,158 views
0 votes
1 answer

ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' (unknown location)

Hi@akhtar, I think there is a problem in ...READ MORE

Apr 22, 2020 in Python by MD
• 95,440 points
7,157 views
0 votes
1 answer

How to fix error "ERROR: Command errored out with exit status 1: python." when trying to install django-heroku using pip

Just add the package containing the executable pg_config. ...READ MORE

Apr 28, 2022 in Python by narikkadan
• 63,620 points
7,107 views
0 votes
1 answer

Python error "'str' object has no attribute 'turtle' in Python turtle"

There is a syntax error. Change the ...READ MORE

Jul 9, 2019 in Python by Pallavi
7,096 views
0 votes
1 answer

Why there is no do while loop in python

There is no do...while loop because there ...READ MORE

Aug 6, 2018 in Python by Priyaj
• 58,090 points
7,084 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,440 points
7,071 views
+1 vote
2 answers

What is the difference between classes and labels in machine learning?

Classes and Labels both are almost same things ...READ MORE

Apr 3, 2019 in Python by SA
• 1,090 points
7,054 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,440 points
7,037 views
+1 vote
0 answers

How to close a window, and then reinitialize it using PyQt

There is a button "btn_closeWin_and_reinit"  in the ...READ MORE

Jul 10, 2019 in Python by marceepoo
• 130 points

edited Jul 22, 2019 by Kalgi 7,020 views
0 votes
1 answer

Error: “ 'dict' object has no attribute 'iteritems' ”?

Hii, In Python2, dictionary.iteritems() is more efficient than ...READ MORE

Apr 13, 2020 in Python by Niroj
• 82,880 points
7,004 views
0 votes
0 answers

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I am facing an error when decoding ...READ MORE

May 9, 2022 in Python by Kichu
• 19,050 points
7,000 views
0 votes
1 answer

Python convert all sheets of excel to csv

You will have to parse through the ...READ MORE

Feb 9, 2019 in Python by Omkar
• 69,210 points
6,995 views
0 votes
1 answer

Open a file if it exists or create and open it does not exists - Python

You can use this: f = open("ex.txt","w+") Here the ...READ MORE

Jun 20, 2019 in Python by Jason
6,962 views
0 votes
1 answer

compare two csv files and print the unique string in 3rd csv file.

Hi, @Smilish, I hope this below code will ...READ MORE

Jun 1, 2020 in Python by Gitika
• 65,910 points
6,953 views
0 votes
1 answer

How to change the width of form elements created with ModelForm in Django?

Hello @kartik, The easiest way for your use ...READ MORE

Jul 29, 2020 in Python by Niroj
• 82,880 points
6,941 views
0 votes
2 answers

Recursive Pattern Using Python

n = int(input("please enter your no:")) k = ...READ MORE

Jun 28, 2020 in Python by Shaurya Thapliyal
• 340 points
6,923 views
0 votes
1 answer

Convert python code into lambda function

This should work: add = lambda x, y ...READ MORE

May 23, 2019 in Python by Payal
6,910 views
0 votes
1 answer

How to create LIST from CSV file in Python?

You can use the pandas library for this which ...READ MORE

Jul 15, 2019 in Python by Karan
6,895 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,440 points
6,890 views
0 votes
1 answer

What is the best way to remove accents in a Python unicode string?

Hello @kartik, Some languages have combining diacritics as ...READ MORE

May 11, 2020 in Python by Niroj
• 82,880 points
6,886 views
0 votes
1 answer

How do I draw a hexagon using the turtle module of python?

Hey @Jinu, try this: import turtle polygon = ...READ MORE

Jun 23, 2019 in Python by Haseeb
6,835 views
0 votes
2 answers

Invalid Token in Python

in python version 2.7,3.6.8 you can't write ...READ MORE

Jun 25, 2020 in Python by ker
6,825 views
0 votes
1 answer

Is there a scanf() or sscanf() equivalent in python?

There is nothing as such for python. For ...READ MORE

Jul 30, 2019 in Python by Greg
6,817 views
0 votes
1 answer

Python error "Python NameError: global name 'Thread' is not defined"

There is a built-in function with the ...READ MORE

May 31, 2019 in Python by Riya
6,806 views
0 votes
1 answer

How to print pandas Dataframe without index?

You can print the dataframe without index ...READ MORE

Mar 28, 2019 in Python by Shri
6,766 views
0 votes
1 answer

pandas._libs.tslib.OutOfBoundsDatetime: Out of bounds nanosecond timestamp

Hi@akhtar, I think you need to upgrade or reinstall ...READ MORE

Jul 16, 2020 in Python by MD
• 95,440 points
6,751 views