Trending questions in Python

+1 vote
1 answer

Why is openpyxl is required for loading excel format files?

Well, it sounds like openpyxl is not ...READ MORE

Aug 8, 2018 in Python by Priyaj
• 58,090 points
793 views
+1 vote
1 answer

How can I map input to output without using dynamic()

Here am talking about my example you ...READ MORE

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

Install pip in Python 3.4

Don't worry! Python already comes in default ...READ MORE

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

.pyc files in python

.pyc files contain the bytecode which are ...READ MORE

Jun 22, 2018 in Python by Hamartia's Mask
• 1,580 points
733 views
0 votes
1 answer

dunder main in python

It is a check to see if ...READ MORE

Jun 21, 2018 in Python by Hamartia's Mask
• 1,580 points
780 views
0 votes
1 answer

Representing infinity

import math infinity = math.inf Now you can use ...READ MORE

Jun 27, 2018 in Python by Hamartia's Mask
• 1,580 points
513 views
0 votes
1 answer

Multiple line comment in python

No, you can simply use triple codes ...READ MORE

Jun 28, 2018 in Python by v.liyyah
• 1,300 points
441 views
0 votes
1 answer

Modules and Packages

A module is a single file imported ...READ MORE

Jun 27, 2018 in Python by Hamartia's Mask
• 1,580 points
446 views
0 votes
1 answer

Convert dictionary keys to a list

list.(dictionary.keys()) READ MORE

Jun 28, 2018 in Python by Hamartia's Mask
• 1,580 points
388 views
0 votes
1 answer

Chaining comparision

I assume you are talking about this ...READ MORE

Jun 26, 2018 in Python by Hamartia's Mask
• 1,580 points
434 views
0 votes
1 answer

Searching for substrings

Use the in operator to do this. If ...READ MORE

Jun 28, 2018 in Python by Hamartia's Mask
• 1,580 points
349 views
0 votes
1 answer

Copying dictionaries

Deep copy -  dict2 = dict(dict1) Shallow copy - dict2 ...READ MORE

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

How to sort a list of strings?

Basic answer: mylist = ["b", "C", "A"] mylist.sort() This modifies ...READ MORE

Jun 4, 2018 in Python by aryya
• 7,450 points
1,258 views
0 votes
1 answer

convert integer to strings

Yes, you can str() function. For example: a=10 str(a) output-' ...READ MORE

Jun 26, 2018 in Python by code.reaper12
• 3,500 points
323 views
0 votes
1 answer

Call a shell command in Python?

Try this - os.system("commands and arguments") READ MORE

Jun 21, 2018 in Python by Hamartia's Mask
• 1,580 points
506 views
0 votes
1 answer

List all contents of a folder

Use listfor() from the os library READ MORE

Jun 22, 2018 in Python by Hamartia's Mask
• 1,580 points
436 views
0 votes
1 answer

Creating a matrix in Python

You can create arrays of any number ...READ MORE

Jun 19, 2018 in Python by Hamartia's Mask
• 1,580 points
552 views
0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

Apr 17, 2018 in Python by anonymous
3,244 views
0 votes
2 answers

Finding the index of a character in python string

You can use word.find('o') as well to ...READ MORE

Jun 1, 2018 in Python by george
• 200 points
1,260 views
0 votes
1 answer

Copying files

copyfile(src, dst) This is from the shutil library https://d ...READ MORE

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

Split a string into a list of characters

This is easy. Just use the list() ...READ MORE

Jun 19, 2018 in Python by Hamartia's Mask
• 1,580 points
491 views
0 votes
1 answer

Extract element from a set without removing it

Use iter(): element = next(iter(set_1)) READ MORE

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

How to get the size of a string in Python?

If you are talking about the length ...READ MORE

Jun 4, 2018 in Python by aryya
• 7,450 points
1,097 views
0 votes
1 answer

Pythonic Switch statement

You can implement it using dictionaries  def numbers_to_strings(argument): ...READ MORE

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

Need help writing a dataframe into a csv with the help of a loop

Using the following logic you can arrive ...READ MORE

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

Deleting files

Use the rmtree() method from shutil library. ...READ MORE

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

Using sequences

Lists are like arrays, except that their ...READ MORE

Jun 14, 2018 in Python by Hamartia's Mask
• 1,580 points
562 views
0 votes
1 answer

Print contents of a folder

There is a function provided in python ...READ MORE

Jun 18, 2018 in Python by Hamartia's Mask
• 1,580 points
372 views
0 votes
1 answer

Sorting a dictionary

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

Jun 18, 2018 in Python by Hamartia's Mask
• 1,580 points
363 views
0 votes
1 answer

Remove a string suffix

You can remove the substring using slicing. ...READ MORE

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

Compare dates

>>> from datetime import datetime >>> past = ...READ MORE

Jun 14, 2018 in Python by Hamartia's Mask
• 1,580 points
502 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
384 views
0 votes
1 answer

Using exceptions in Python

They are used for control flow. Check ...READ MORE

Jun 14, 2018 in Python by Nietzsche's daemon
• 4,260 points
394 views
0 votes
1 answer

Install mysqldb module

pip install mysqlclient READ MORE

Jun 12, 2018 in Python by Hamartia's Mask
• 1,580 points
452 views
0 votes
1 answer

Python Whitespace for indenting

PEP-8 recommends creating indents by tapping the ...READ MORE

Jun 12, 2018 in Python by Hamartia's Mask
• 1,580 points
418 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
600 views
0 votes
2 answers

Delete a character from pythons string

If you want to remove the 'J' ...READ MORE

Jun 12, 2018 in Python by anonymous
468 views
0 votes
1 answer

Looping over two lists at once

You have to use the zip() function: for ...READ MORE

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

Can someone explain the behaviour of increment and decrement operators in python

down voteaccepted ++ is not an operator. It is ...READ MORE

May 15, 2018 in Python by aryya
• 7,450 points
1,520 views
0 votes
1 answer

Binary numbers in python

>>> 0b1011 11 READ MORE

Jun 6, 2018 in Python by Hamartia's Mask
• 1,580 points
564 views
0 votes
1 answer

Swapping values

a,b = b,a Here, python interprets the comma ...READ MORE

Jun 8, 2018 in Python by Hamartia's Mask
• 1,580 points
451 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
600 views
0 votes
1 answer

How can I get a list of locally installed Python modules?

Solution My 50 cents for getting a pip freeze-like ...READ MORE

May 24, 2018 in Python by charlie_brown
• 7,720 points
1,024 views
0 votes
1 answer

Combine list items to a string

>>> stmt = ['this','is','a','statement'] >>> ' '.join(sentence) 'this is ...READ MORE

Jun 7, 2018 in Python by Hamartia's Mask
• 1,580 points
391 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
377 views
0 votes
1 answer

What are the differences between type() and isinstance()?

To summarize the contents of other (already ...READ MORE

Jun 4, 2018 in Python by aryya
• 7,450 points
496 views
0 votes
1 answer

Extract all characters of a string

Convert it to a list -  s = ...READ MORE

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

Using Lists and Tuples in Python

if you are familiar with C programming, ...READ MORE

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

Size of an object in Python

Use sys.getsizeof() function: >>> import sys >>> s = ...READ MORE

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

multi line comment

‘’’ This is the way to Enter multi ...READ MORE

Jul 16, 2018 in Python by Priyaj
• 58,090 points
415 views