Most viewed questions in Python

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
393 views
0 votes
1 answer

How to merge two dictionaries in a single expression?

In Python 3.5 or greater: z = {**x, ...READ MORE

Mar 13, 2019 in Python by Trisha
393 views
0 votes
1 answer

Enlarging a list using functions using append() and extend()

Let me illustrate this with an example ...READ MORE

Jun 1, 2018 in Python by Nietzsche's daemon
• 4,260 points
393 views
0 votes
0 answers

In Python, how do I declare an array?

In Python, how do I declare an ...READ MORE

Nov 17, 2022 in Python by Samuel
• 460 points
392 views
0 votes
0 answers

'str' object has no attribute 'decode'. Python 3 error?

'decode' is not an attribute of the ...READ MORE

Sep 21, 2022 in Python by Samuel
• 460 points
392 views
0 votes
0 answers

How do you install python 3.6 in linux?

I am having trouble choosing interpreter as ...READ MORE

Jul 24, 2019 in Python by Waseem
• 4,540 points
392 views
0 votes
0 answers

How does pillow work in opening and closing images in python?

Is there a separate library that we ...READ MORE

Jul 16, 2019 in Python by Waseem
• 4,540 points
392 views
+1 vote
1 answer

Accessing the index in 'for' loops?

Using an additional state variable, such as ...READ MORE

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

Not able to print cell value by index.

You have wrongly indexed. The index you ...READ MORE

Apr 8, 2019 in Python by Ganesh
391 views
0 votes
1 answer

Need help understanding python code

In this particular code, I think you ...READ MORE

Feb 19, 2019 in Python by Omkar
• 69,230 points
391 views
0 votes
1 answer

How to use an index to get an item?

What you show, ('A','B','C','D','E'), is not a ...READ MORE

Jan 30, 2019 in Python by SDeb
• 13,300 points
391 views
0 votes
1 answer

Meta classes in Python

A Metaclass is the class of a ...READ MORE

Oct 31, 2018 in Python by SDeb
• 13,300 points
391 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
390 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
390 views
0 votes
1 answer

Does array element contain substring?

Loop through the $forbiddennames array and use stripos to check if ...READ MORE

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

how can I save my output of xml parsing in excel file...?

Hi, @Arjmand, I would suggest you go through ...READ MORE

Dec 23, 2020 in Python by Gitika
• 65,910 points
388 views
0 votes
0 answers

Can we create a empty dataframe in python?

I want to create an empty dataframe ...READ MORE

Aug 7, 2019 in Python by Waseem
• 4,540 points
388 views
0 votes
0 answers

Derivative of manipulated spline

I am using the InterpolatedUnivariateSpline function from ...READ MORE

Oct 4, 2018 in Python by eatcodesleeprepeat
• 4,710 points
388 views
+1 vote
1 answer

Unzipping files in Python

Use this code: import zipfile with zipfile.ZipFile(path_to_zip_file, 'r') as ...READ MORE

Apr 25, 2022 in Python by narikkadan
• 63,700 points
386 views
0 votes
1 answer

The below code prints none at the end.

the code after return does not execute. ...READ MORE

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

What is selenium in python?

It is known as Web automations, It is ...READ MORE

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

Scripts along with pytype

Pytype ships with three scripts in addition ...READ MORE

Jun 7, 2019 in Python by Greg
386 views
0 votes
1 answer

Add new keys to a dictionary?

>>> d = {'key':'value'} >>> print(d) {'key': ...READ MORE

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

Is there a label/goto in Python?

Since Python is a structured programming language, ...READ MORE

Feb 4, 2022 in Python by Nandini
• 5,480 points
385 views
0 votes
1 answer

Error "Failed to load tensorflow runtime"

Hello, Try to downgrade protobuf, this worked for ...READ MORE

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

Why does -22 // 10 return -3? - Python

Why does -22 // 10 return -3 ...READ MORE

Jul 30, 2019 in Python by Ashish
385 views
0 votes
1 answer

How do I add a button - Python

Try this: # Import required packages import Tkinter import tkMessageBox top ...READ MORE

Jul 22, 2019 in Python by Ashish
385 views
0 votes
1 answer

zeropad all the arrays to match the largest array in that file in python

You can try something like this: import numpy ...READ MORE

May 29, 2019 in Python by Wazeer
385 views
0 votes
1 answer

can you give an example to get a random sample dictionary?

Check below code thisdict = { "1": ...READ MORE

Nov 25, 2021 in Python by anonymous
385 views
0 votes
1 answer

Size of an open file object

You can use the following and try ...READ MORE

Jan 22, 2019 in Python by SDeb
• 13,300 points
385 views
0 votes
1 answer

reversing a list

Use the reverse function!  list_1.reverse() READ MORE

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

How does function definition work in python?

Is it same as other programming languages ...READ MORE

Jun 13, 2019 in Python by Waseem
• 4,540 points
384 views
0 votes
0 answers

How can we read a text file in a list in python?

Can you give the sample code as ...READ MORE

Jun 18, 2019 in Python by Waseem
• 4,540 points
383 views
0 votes
1 answer

Can I make incompatible changes to Python?

Hi @Zaid, It's actually not very cool ...READ MORE

Jun 7, 2019 in Python by Greg
383 views
0 votes
1 answer

Renaming columns of dataframes

Assign the new names to the column ...READ MORE

May 3, 2018 in Python by Nietzsche's daemon
• 4,260 points
383 views
0 votes
1 answer

How do I check if a given Python string is a substring of another one?

Try using in like this: >>> x = 'hello' >>> y ...READ MORE

Nov 26, 2020 in Python by Gitika
• 65,910 points
382 views
0 votes
0 answers

can i send an email using python?

can you give me the exact code ...READ MORE

Apr 4, 2019 in Python by Waseem
• 4,540 points
382 views
0 votes
1 answer

Modify int in place

Use a list rather than a tuple: my_container ...READ MORE

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

Multiple line comment in Python

Try this ''' This is a multiline comment. I can ...READ MORE

May 31, 2018 in Python by charlie_brown
• 7,720 points
382 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 17, 2020 in Python by Nikita
381 views
0 votes
0 answers

How to do proper formatting of XML differences in dictionary using python 3.4.4

Need help in formatting the output. Please ...READ MORE

Jun 19, 2020 in Python by Abhinandan
• 120 points

edited Jun 19, 2020 by Abhinandan 381 views
0 votes
0 answers

what is the logical AND operator in python?

how do i use it in a ...READ MORE

Apr 12, 2019 in Python by Waseem
• 4,540 points
381 views
0 votes
1 answer

Converting integer to string in Python

In order to convert an object to string ...READ MORE

Feb 11, 2022 in Python by Dev
• 6,000 points
380 views
0 votes
1 answer

How to run code when a class is subclassed?

Classes (by default) are instances of the ...READ MORE

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

char list from 0 to f

The simplest way would be a list ...READ MORE

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

How to display rows of one dataframe in a concatenated dataframe?

You can do this only if you ...READ MORE

May 14, 2019 in Python by Esha
379 views
0 votes
1 answer

How to append a Python List?

Please refer to the below code to ...READ MORE

Apr 4, 2019 in Python by Giri
378 views
0 votes
1 answer

Create an empty array

You don't have to. The size of ...READ MORE

Jun 7, 2018 in Python by Hamartia's Mask
• 1,580 points
378 views
0 votes
0 answers

Need to create rds instances under already existing subnets created in 3 az's, please help

I created subnets in three different az's. ...READ MORE

Feb 23, 2020 in Python by saiarun
• 150 points
377 views
0 votes
0 answers

How do you perform selection sort in python?

Can you sort a list with n ...READ MORE

Jun 21, 2019 in Python by Waseem
• 4,540 points
377 views