Most viewed questions in Python

0 votes
1 answer

What is the output of and explanation?

It will print concatenated lists. Output would ...READ MORE

Jul 20, 2018 in Python by Priyaj
• 58,090 points
604 views
0 votes
0 answers

pass optional or keyword parameters from one function to another in python?

How can I pass optional or keyword ...READ MORE

Jul 24, 2019 in Python by Hari
603 views
0 votes
1 answer

What does the map() method do in Python?

The map() function in Python is a ...READ MORE

Jun 17, 2019 in Python by anonymous
603 views
0 votes
2 answers

Replacements for switch statement in Python?

The recommended path for Python 3.10 which ...READ MORE

Feb 9, 2022 in Python by Soham
• 9,700 points
603 views
0 votes
2 answers

Obtaining a value when given a key in python dicionaries

Yes you can check below code dictionary = ...READ MORE

Nov 25, 2021 in Python by Suhas
603 views
0 votes
1 answer

How to convert string to date in python with different algorithms ?

Hello @ pagarsach, You can convert a string to ...READ MORE

Jun 30, 2020 in Python by Niroj
• 82,880 points
602 views
0 votes
0 answers

I am trying to build a pong game this is what they showed me.

import turtle wn = turtle.Screen() wn.bgcolor("blue") wn.tracer(0) #Paddle A paddle_a = turtle.Turtle() paddle_a.speed(0) paddle_a.shape("square") paddle_a.color("red") paddle_a.ShapeSize paddle_a.penup() paddle_a.goto(-350, ...READ MORE

May 23, 2020 in Python by Praise
• 120 points

edited May 25, 2020 by Gitika 602 views
0 votes
1 answer

Unable to take input from user in Python

num = input("enter number") print(num) READ MORE

May 1, 2018 in Python by aayushi
• 750 points
602 views
0 votes
1 answer

How to check Django version

The Django 1.5 supports the Python 2.6.5 ...READ MORE

Feb 22, 2022 in Python by Aditya
• 7,680 points
601 views
0 votes
1 answer

How can I represent an Enum in Python?

Here is one implementation: class Enum(set): ...READ MORE

Dec 11, 2018 in Python by aryya
• 7,450 points
601 views
0 votes
1 answer

Understanding Python's slice notation

It's pretty simple really: a[start:end] # items start ...READ MORE

Oct 25, 2018 in Python by SDeb
• 13,300 points
601 views
+1 vote
1 answer

Can installin pip for python install dependencies aswell?

As long as the dependency is listed ...READ MORE

Sep 26, 2018 in Python by Priyaj
• 58,090 points
601 views
0 votes
1 answer

Normal Python code equivalent to given list comprehension

You can try this code list1=[] for i in ...READ MORE

Jun 8, 2018 in Python by jain12
• 170 points
601 views
0 votes
1 answer

How to read/process command line arguments?

The canonical solution in the standard library ...READ MORE

Jun 4, 2018 in Python by aryya
• 7,450 points
601 views
0 votes
0 answers

I am trying to click the button but it is not working and it is drop list ..

<a class="quickreports btn btn3d tbbtn" href="javascript:" style="position:static" ...READ MORE

Dec 2, 2019 in Python by anonymous
• 120 points
600 views
0 votes
0 answers

How to make abstract classes in python?

How do you make a class, abstract ...READ MORE

Aug 26, 2019 in Python by Waseem
• 4,540 points
599 views
0 votes
2 answers

Get key by value in dictionary

I have slightly modified your program to ...READ MORE

Nov 25, 2021 in Python by Python Coder
599 views
0 votes
1 answer

When to use super(type) in python?

super(x) returns an "unbound" descriptor, that is, ...READ MORE

Jun 3, 2019 in Python by SDeb
• 13,300 points
599 views
0 votes
1 answer

What is getattr() exactly and how do I use it?

You can view a full example here: http://www.diveintopython.net/power_of_introspection/index.html Introspection ...READ MORE

Sep 17, 2018 in Python by bug_seeker
• 15,520 points
599 views
+5 votes
1 answer

What are metaclasses in Python?

A metaclass instantiates and defines behavior for ...READ MORE

Sep 11, 2018 in Python by Priyaj
• 58,090 points
599 views
0 votes
1 answer

Need help with searching a binary search tree

Instead of multiplying the number of nodes ...READ MORE

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

How to read a large file, line by line, in Python?

The correct, fully Pythonic way to read ...READ MORE

Jul 1, 2019 in Python by SDeb
• 13,300 points
598 views
0 votes
1 answer

How do I check if a list is empty?

You can try the following: if not a:   print("List ...READ MORE

Mar 14, 2019 in Python by SDeb
• 13,300 points
598 views
0 votes
1 answer

Examples for string find in Python

you can use str.index too: >>> 'sdfasdf'.index('cc') Traceback ...READ MORE

Aug 29, 2018 in Python by Priyaj
• 58,090 points
598 views
0 votes
1 answer

Reverse a string in Python

>>> 'hello world'[::-1] 'dlrow olleh' This is extended slice syntax. It ...READ MORE

Feb 15, 2022 in Python by CoolCoder
• 4,400 points
597 views
+1 vote
1 answer

Can assignment operator be used to copy elements in Python?

Yes assignment operator can be used to ...READ MORE

Jul 29, 2019 in Python by Neel
• 3,020 points

edited Jul 30, 2019 by Neel 597 views
0 votes
1 answer

Hive client for Python 3.x

If you have HiveServer2 installed you can ...READ MORE

May 29, 2019 in Python by SDeb
• 13,300 points
597 views
0 votes
1 answer

How Lambda() is used with filter() in python?

The filter() function in Python takes in ...READ MORE

May 20, 2019 in Python by Rakshi
597 views
0 votes
1 answer

How to start IDLE in windows?

It comes with the official python setup. ...READ MORE

Aug 19, 2019 in Python by Mohammad
• 3,230 points
596 views
0 votes
1 answer

Deleting elements from numpy array

Use the following code: import numpy as np a=np.array([1,2,3,4]) b=np.delete(a,2) OUTPUT: array([1, ...READ MORE

Jun 24, 2019 in Python by Fata
• 1,050 points

edited Jun 25, 2019 by Kalgi 596 views
0 votes
1 answer

Merge two dicts

dict3 = dict1.copy() # merges ...READ MORE

Apr 27, 2018 in Python by Nietzsche's daemon
• 4,260 points
596 views
0 votes
1 answer

How do I run a set of code for all the requests in Flask?

Hi, You can use dedicated hooks(decorators) called before ...READ MORE

Jun 21, 2019 in Python by Shabnam
• 930 points
595 views
0 votes
0 answers

what is the use of args and kwargs in python?

can you an example for each? READ MORE

May 11, 2019 in Python by Waseem
• 4,540 points
595 views
0 votes
1 answer

How to remove the duplicate values in a list?

a = [10,20,30,40,10,20,30,40,30,40,50,60] s = set(a) c = list(s) print(c) this ...READ MORE

Mar 20, 2019 in Python by Mohammad
• 3,230 points
595 views
0 votes
1 answer

Pytype checker funtion

Pytype checks and infers types for your ...READ MORE

Jun 7, 2019 in Python by Fez
594 views
0 votes
1 answer

Weird closure behavior in python

Closures don't refer to variables but rather ...READ MORE

Feb 2, 2019 in Python by SDeb
• 13,300 points
592 views
0 votes
1 answer

Is there a built-in module to handle excel files in python?

You can use the module - openpyxl ...READ MORE

Aug 19, 2019 in Python by Mohammad
• 3,230 points
591 views
0 votes
1 answer

Install matplotlib - Python

Execute the following commands to install matplotlib ...READ MORE

May 30, 2019 in Python by Tara
591 views
0 votes
3 answers

How to add a new item to a dictionary in Python?

There is no add() , append() , or insert() method ...READ MORE

Jan 4, 2021 in Python by Reshma
590 views
0 votes
1 answer

Persisting data in sklearn

If you want to find some fixed ...READ MORE

Jul 10, 2019 in Python by SDeb
• 13,300 points
590 views
0 votes
1 answer

How do I turn a list into numpy array?

Use this line: numpy_array = np.array(list) And printing/displaying the ...READ MORE

May 24, 2019 in Python by Isha
589 views
0 votes
1 answer

Balanced binary tree python

Instead of multiplying the number of nodes ...READ MORE

Sep 12, 2018 in Python by Priyaj
• 58,090 points
589 views
0 votes
1 answer

How to hide a window in the constructor immediately after creation?

You can use QtCore.QTimer class Example(QWidget):     def __init__(self, app):         QWidget.__init__(self)         QTimer.singleShot(0, ...READ MORE

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

Install virtualenv - python

Follow these steps to install virtualenv on ...READ MORE

Oct 7, 2019 in Python by Harshit
588 views
0 votes
1 answer

Removing surrounding whitespace

Try the strip() function:  s = s.strip() If you ...READ MORE

May 4, 2018 in Python by Nietzsche's daemon
• 4,260 points
588 views
0 votes
0 answers

Python - TypeError: 'int' object is not iterable

Here's my code: import math print("Hey, lets solve Task ...READ MORE

Dec 21, 2022 in Python by erzan
• 630 points
587 views
0 votes
1 answer

Unable to create a project in django.

I think u didn't install Django. python -m ...READ MORE

Nov 12, 2020 in Python by Gitika
• 65,910 points
587 views
0 votes
0 answers

Creating a mini language parser using Python

I'm planning to create a simple mini-language ...READ MORE

Dec 27, 2018 in Python by Anirudh
• 2,080 points
586 views
0 votes
1 answer

Numpy data in csv

Use this -  numpy.savetxt("data.csv", arr, delimiter=",") READ MORE

Jul 3, 2018 in Python by Hamartia's Mask
• 1,580 points
586 views
0 votes
1 answer

How to approach the problem of finding the nearest square?

The following method should solve this.  def nearest_square(limit): ...READ MORE

Jul 10, 2019 in Python by Neel
• 3,020 points
585 views