Trending questions in Python

+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
1,278 views
0 votes
1 answer

How to split a string into a list?

You can use the function  text.split() This should be ...READ MORE

Jul 30, 2018 in Python by Priyaj
• 58,020 points
874 views
0 votes
1 answer

Python: list of lists

Lists are a mutable type - in ...READ MORE

Aug 2, 2018 in Python by bug_seeker
• 15,510 points
741 views
0 votes
1 answer

Python 'If not' syntax

Yes, if bar is not None is ...READ MORE

Aug 1, 2018 in Python by Priyaj
• 58,020 points
784 views
+4 votes
3 answers

What does these operator mean **, ^, %, // ?

** - Performs exponential (power) calculation on ...READ MORE

Apr 12, 2018 in Python by anto.trigg4
• 3,440 points
1,388 views
0 votes
1 answer

Python join: why is it string.join(list) instead of list.join(string)?

This is because join is a "string" ...READ MORE

Jul 30, 2018 in Python by Priyaj
• 58,020 points
820 views
0 votes
1 answer

How to add to the python path in Windows?

You know what has worked for me ...READ MORE

Jul 25, 2018 in Python by Frankie
• 9,830 points
1,026 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,646 views
0 votes
1 answer

What is the Python equivalent for a case/switch statement?

if x == 'a':  # Do the ...READ MORE

Jul 26, 2018 in Python by Priyaj
• 58,020 points
959 views
0 votes
1 answer

How do I sort a dictionary by value?

It is not possible to sort a ...READ MORE

Jul 30, 2018 in Python by Priyaj
• 58,020 points
753 views
0 votes
1 answer

How to import other Python files?

importlib is recent addition in Python to ...READ MORE

Jul 27, 2018 in Python by Priyaj
• 58,020 points
880 views
+2 votes
2 answers

In a list of dictionaries, how can I find the minimum calue in a common dictionary field.

There are several options. Here is a ...READ MORE

Apr 10, 2018 in Python by charlie_brown
• 7,720 points
1,413 views
0 votes
1 answer

How to sort a list of strings?

Try  items = ["live", "like", "code", "cool", "bug"] ...READ MORE

Jul 27, 2018 in Python by Priyaj
• 58,020 points
845 views
0 votes
2 answers

Splitting a Python String

The split() method in Python returns a ...READ MORE

Oct 3, 2018 in Python by anonymous
692 views
0 votes
1 answer

How to use “raise” keyword in Python

You can use it to raise errors ...READ MORE

Jul 30, 2018 in Python by Priyaj
• 58,020 points
684 views
0 votes
1 answer

Understanding the map function

map isn't particularly pythonic. I would recommend ...READ MORE

Jul 31, 2018 in Python by Priyaj
• 58,020 points
633 views
+1 vote
1 answer

Appending data to a file [closed]

To append a file without overwriting, open ...READ MORE

Aug 7, 2018 in Python by Omkar
• 69,220 points

edited Aug 7, 2018 by Omkar 622 views
0 votes
1 answer

Python - convert string to list

states.split() will return ['Alaska', 'Alabama', 'Arkansas', 'American', 'Samoa', ...READ MORE

Jul 25, 2018 in Python by Frankie
• 9,830 points
822 views
0 votes
1 answer

Difference between pop and delete methods

I think you mean del() and not ...READ MORE

Jun 25, 2018 in Python by Hamartia's Mask
• 1,580 points
2,123 views
0 votes
1 answer

Python - convert string to list

try states.split() this would help. READ MORE

Jul 20, 2018 in Python by Priyaj
• 58,020 points
1,007 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
1,035 views
0 votes
1 answer

How to get the current time in Python

>>> import datetime >>> datetime.datetime.now() datetime(2018, 25, ...READ MORE

Jul 25, 2018 in Python by Frankie
• 9,830 points
758 views
0 votes
1 answer

Best way to create a simple python web service

web.py is probably the simplest web framework ...READ MORE

Jul 20, 2018 in Python by Priyaj
• 58,020 points
909 views
0 votes
1 answer

How do you append to a file?

with open("test.txt", "a") as myfile: myfile.write("appended text ...READ MORE

Jul 27, 2018 in Python by Priyaj
• 58,020 points
608 views
0 votes
1 answer

How to properly ignore Exceptions?

try:  doSomething() except:  pass or try:  doSomething() except Exception: ...READ MORE

Jul 26, 2018 in Python by Priyaj
• 58,020 points
612 views
+2 votes
2 answers

How can I create a new file in Python?

You can try the below code which ...READ MORE

Mar 31, 2018 in Python by anto.trigg4
• 3,440 points
1,306 views
0 votes
1 answer

Python Null Object

Use the 'None' keyword to denote the ...READ MORE

Jul 20, 2018 in Python by Nietzsche's daemon
• 4,260 points
835 views
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,020 points
842 views
0 votes
1 answer

__all__ in python

That is the list of public objects ...READ MORE

Jul 20, 2018 in Python by Nietzsche's daemon
• 4,260 points
820 views
0 votes
1 answer

*args and **kwargs in python

In cases when we don’t know how ...READ MORE

Jul 20, 2018 in Python by Priyaj
• 58,020 points
825 views
0 votes
1 answer

Connect to a MySQL DB in python?

db = MySQLdb.connect(host="localhost", # ...READ MORE

Jul 20, 2018 in Python by Nietzsche's daemon
• 4,260 points
768 views
0 votes
1 answer

Deleting a list element by index

Use the del() function del a[2] Or you can ...READ MORE

Jul 20, 2018 in Python by Nietzsche's daemon
• 4,260 points
741 views
0 votes
1 answer

Mean and average in numpy

np.average() can be used to calculate weighted ...READ MORE

Jul 20, 2018 in Python by Nietzsche's daemon
• 4,260 points
721 views
0 votes
1 answer

Accessing Environment variables

import os print(os.environ['HOME']) READ MORE

Jul 20, 2018 in Python by Nietzsche's daemon
• 4,260 points
695 views
0 votes
1 answer

Monkey Patching

Dynamically modifying a class or module at ...READ MORE

Jul 20, 2018 in Python by Priyaj
• 58,020 points
701 views
+2 votes
2 answers

How to use BeatifulSoup for webscraping?

your programme is fine until you start ...READ MORE

Apr 4, 2018 in Python by charlie_brown
• 7,720 points
1,067 views
0 votes
1 answer

What are the key features of Python?

If it makes for an introductory language ...READ MORE

Jul 20, 2018 in Python by Priyaj
• 58,020 points
640 views
0 votes
1 answer

What is the flow control for “continue” in python?

This is the way "continue" statement works! You ...READ MORE

Jul 16, 2018 in Python by Priyaj
• 58,020 points
764 views
0 votes
1 answer

init.py file

It is used to denote directories on ...READ MORE

Jul 20, 2018 in Python by Nietzsche's daemon
• 4,260 points
545 views
0 votes
1 answer

Random selections from list

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

Jul 20, 2018 in Python by Nietzsche's daemon
• 4,260 points
544 views
0 votes
1 answer

Appending data to a file [closed]

with open("test.txt", "a") as myfile: ...READ MORE

Jul 20, 2018 in Python by Nietzsche's daemon
• 4,260 points
540 views
0 votes
0 answers

Storing a list of arrays into a CSV file and retrieving it back in a different program

This is the code that I am ...READ MORE

Jun 7, 2018 in Python by aryya
• 7,460 points
2,382 views
0 votes
1 answer

Combining numpy arrays

There is concatenation function for numpy arrays ...READ MORE

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

Difference between two lists in python

difference = list(set(list1) - set(list2)) READ MORE

May 24, 2018 in Python by Nietzsche's daemon
• 4,260 points
2,814 views
0 votes
1 answer

TkInter Grid Overlapping Issue

Tkinter is fairly efficient. And for the ...READ MORE

Apr 17, 2018 in Python by anonymous
4,321 views
0 votes
2 answers

Lists and Tuples

Lists are mutable homogeneous sequences whereas tuples ...READ MORE

Jul 17, 2018 in Python by Mrunal
• 680 points
666 views
0 votes
1 answer

Append & Extend

Hi. This question has already been answered. Take ...READ MORE

Jul 2, 2018 in Python by Nietzsche's daemon
• 4,260 points
870 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
827 views
+1 vote
1 answer

How to create plots using python matplotlib in IPython notebook?

I think you should try: I used %matplotlib inline in ...READ MORE

Aug 8, 2018 in Python by Priyaj
• 58,020 points
1,576 views
0 votes
1 answer

Raw_input method is not working in python3. How to use it?

raw_input is not supported anymore in python3. ...READ MORE

May 5, 2018 in Python by aayushi
• 750 points
3,361 views