Most voted questions in Python

+1 vote
4 answers

Comparing input functions

In Python raw_input() allows you to enter ...READ MORE

Oct 18, 2018 in Python by fuji
1,383 views
+1 vote
8 answers

Count the frequency of an item in a python list

To count the number of appearances: from collections ...READ MORE

Oct 18, 2018 in Python by tinitales
35,257 views
+1 vote
4 answers

How can I concatenate str and int objects?

If you want to concatenate int or ...READ MORE

Oct 18, 2018 in Python by subhm
935 views
+1 vote
2 answers

View onto a numpy array?

 just index it as you normally would. ...READ MORE

Oct 18, 2018 in Python by roberto
694 views
+1 vote
5 answers

convert string to int python

Using list comprehensions: t2 = [map(int, list(l)) for ...READ MORE

Oct 18, 2018 in Python by donald
1,310 views
+1 vote
6 answers

How python trim works

You want strip(): myphrases = [ " Hello ...READ MORE

Oct 18, 2018 in Python by up4rescue
996 views
+1 vote
4 answers

How to write nested dictionaries to a CSV file

Using DictWriter there is no need in ...READ MORE

Oct 18, 2018 in Python by Richard William
26,845 views
+1 vote
5 answers

Check whether the file exists or not?

Use this import os os.path.exists(path) # Returns whether the ...READ MORE

Oct 18, 2018 in Python by reyam
1,600 views
+1 vote
2 answers

How to resize the image canvas to maintain a square aspect ratio

down voteacceptedUsing OpenCVYou can use resize() in OpenCV to ...READ MORE

Apr 4, 2018 in Python by charlie_brown
• 7,720 points

edited Jul 11, 2023 by Khan Sarfaraz 1,284 views
0 votes
1 answer

What is the algorithm to find the sum of prime numbers in the input in python

To find the sum of prime numbers ...READ MORE

Mar 1 in Python by Shubh Saxena
213 views
0 votes
1 answer

How to Concatenate Lists in Python?

In Python, you can concatenate lists using ...READ MORE

Dec 29, 2023 in Python by Anu
208 views
0 votes
1 answer

Sum of prime numbers from m to n in python

def is_prime(number):     if number < 2:         return False     for i ...READ MORE

Jan 5 in Python by Ali
301 views
0 votes
1 answer

What does // means in Python?

In Python, when you use //, it ...READ MORE

Dec 29, 2023 in Python by Vani
218 views
0 votes
1 answer

Command python execinterminal icon not found

When the "command Python execInTerminal" icon or ...READ MORE

Nov 29, 2023 in Python by anonymous
• 3,320 points
681 views
0 votes
1 answer

Why am I getting the syntax error SyntaxError invalid syntax in a line that contains fully valid syntax?

A "SyntaxError: invalid syntax" is a common ...READ MORE

Oct 18, 2023 in Python by anonymous
• 3,320 points
704 views
0 votes
1 answer

What do "init" and "self" do in python ?

In Python, `init` and `self` are related ...READ MORE

Oct 5, 2023 in Python by anonymous
• 3,320 points
476 views
0 votes
1 answer

Python urllib2 login to minecraft net

Why not use Selenium over urllib? Selenium ...READ MORE

Sep 25, 2023 in Python by Rajarshi
• 470 points
302 views
0 votes
0 answers

How do I install opencv using pip?

I need to install cv2 for a ...READ MORE

Sep 13, 2023 in Python by Rahul
• 200 points
355 views
0 votes
0 answers
0 votes
0 answers
0 votes
0 answers

In Python, retrieve color palettes from the website ColorHunt.co.

I am presently engaged in the development ...READ MORE

Sep 12, 2023 in Python by Satyawrat
• 460 points
230 views
0 votes
0 answers

What do the three different types of brackets in Python code mean? I'm not sure if this is right, so if I'm wrong, please tell me:

[] - Normally used for dictionaries, list items () - ...READ MORE

Sep 11, 2023 in Python by Satyawrat
• 460 points
143 views
0 votes
0 answers

How to find the number of a list item ?

Given a list ["foo", "bar", "baz"] and ...READ MORE

Sep 11, 2023 in Python by Satyawrat
• 460 points
101 views
0 votes
0 answers

I'm making a Python program to do math, figure out answers, and so on, but I'm getting the syntaxerror: "unexpected character after line continuation character in python."

This is my code: print("Length between sides: "+str((length*length)*2.6)+" ...READ MORE

Sep 7, 2023 in Python by Satyawrat
• 460 points
306 views
0 votes
0 answers

I have a very long list of datetime strings like these:

["Jun 1 2005 1:33PM", "Aug 28 1999 ...READ MORE

Sep 7, 2023 in Python by Satyawrat
• 460 points
89 views
0 votes
0 answers

Is it okay for general applications to use the RuntimeError exception?

raise RuntimeError('config file is missing host address') I've ...READ MORE

Sep 7, 2023 in Python by Satyawrat
• 460 points
114 views
0 votes
0 answers

How to use the open with statement to open a file

I'm researching file input and output in ...READ MORE

Sep 6, 2023 in Python by Satyawrat
• 460 points
195 views
0 votes
0 answers
0 votes
0 answers

How does super() operate in the presence of multiple inheritance? As an example, consider the following:

class First(object): def __init__(self): ...READ MORE

Sep 6, 2023 in Python by Satyawrat
• 460 points
211 views
0 votes
0 answers

What does %s in a Python format string mean?

For example, in the below code if len(sys.argv) ...READ MORE

Sep 5, 2023 in Python by Satyawrat
• 460 points
114 views
0 votes
0 answers

How to sort a dictionary using key?

Example input: {2:3, 1:89, 4:5, 3:0} Desired output: {1:89, 2:3, ...READ MORE

Sep 4, 2023 in Python by Satyawrat
• 460 points
94 views
0 votes
0 answers

How to sum the values of a JavaScript object?

I'd like to sum the values of ...READ MORE

Sep 1, 2023 in Python by Edureka
• 220 points
102 views
0 votes
0 answers
0 votes
0 answers

What do __init__ and self do in Python? [duplicate]

During my Python lectures, I've come across a ...READ MORE

Aug 31, 2023 in Python by Edureka
• 220 points
109 views
0 votes
0 answers

Python urllib2 login to minecraft.net

I have a doubt. I'm creating a ...READ MORE

Aug 31, 2023 in Python by Edureka
• 220 points
117 views
0 votes
1 answer

Replacements for switch statement in Python?

To get the same function as a ...READ MORE

Feb 16, 2023 in Python by Rishu
• 300 points
888 views
0 votes
0 answers

Function for factorial in Python

How can I compute an integer's factorial ...READ MORE

Feb 15, 2023 in Python by Arya
• 990 points
527 views
0 votes
1 answer

Removing duplicates in lists

1)To get rid of duplicate items, convert ...READ MORE

Feb 16, 2023 in Python by Rishu
• 300 points
699 views
0 votes
1 answer

Relative imports in Python 3

Because the first statement, from.mymodule import myfunction, ...READ MORE

Feb 16, 2023 in Python by Rishu
• 300 points
725 views
0 votes
1 answer

Error: 'int' object is not subscriptable - Python

int([x[age1]]) You are attempting to access the age1 index ...READ MORE

Feb 16, 2023 in Python by Rishu
• 300 points
687 views
0 votes
1 answer

Why is `(True, True, True) == True, True, True` not True in Python?

Operator precedence. You're actually checking equality between (True, ...READ MORE

Jan 4, 2023 in Python by Elton
• 400 points
476 views
0 votes
1 answer

What is the data type of (1) in python?

Typecasting is the process of converting one ...READ MORE

Jan 4, 2023 in Python by Elton
• 400 points
461 views
0 votes
1 answer

Python Math - TypeError: 'NoneType' object is not subscriptable

“TypeError: 'NoneType' object is not subscriptable” is ...READ MORE

Jan 4, 2023 in Python by Elton
• 400 points
772 views
0 votes
1 answer

How do I use method overloading in Python?

It's method overloading, not method overriding. And in Python, ...READ MORE

Jan 4, 2023 in Python by Elton
• 400 points
299 views
0 votes
1 answer

Python vs Cpython

So what is CPython? CPython is the original Python implementation. ...READ MORE

Jan 4, 2023 in Python by Elton
• 400 points
474 views
0 votes
0 answers

What should I do with "Unexpected indent" in Python?

How do I rectify the error "unexpected ...READ MORE

Dec 22, 2022 in Python by erzan
• 630 points
329 views
0 votes
0 answers

python: SyntaxError: EOL while scanning string literal

I have the above-mentioned error in s1="some ...READ MORE

Dec 22, 2022 in Python by erzan
• 630 points
270 views