Trending questions in Python

+1 vote
1 answer

How to convert records from csv to a list in Python?

If you are using Python 3.x then ...READ MORE

Jun 25, 2019 in Python by Arvind
• 3,050 points

edited Jun 26, 2019 by Kalgi 10,039 views
0 votes
1 answer

Python Selenium: ConnectionRefusedError: No connection could be made because the target machine actively refused it

When you use driver.quit(), it closes the ...READ MORE

Apr 6, 2019 in Python by Tina
13,561 views
+1 vote
1 answer

I have explained my scenario.Please suggest answer for this?

Hi @Vishal, You can simply use an if-else ...READ MORE

Jan 22, 2020 in Python by Kalgi
• 52,350 points
919 views
+1 vote
0 answers

taking partial screenshot with python selenium in linux [closed]

is it possible to take screenshot of ...READ MORE

Jan 21, 2020 in Python by Noor
• 200 points

closed Jan 21, 2020 by Kalgi 931 views
0 votes
1 answer

draw polygon based on user input - turtle python

Try something like this: import turtle # create a ...READ MORE

Jul 6, 2019 in Python by Umer
9,540 views
0 votes
1 answer

Python error "ImportError: No module named SpeechRecognition"

Hi @Hannah, replace  import SpeechRecognition as sr with import speech_recognition ...READ MORE

Oct 3, 2019 in Python by Yamini
5,622 views
0 votes
2 answers

How to lock a thread in Python?

Lock objects can release the lock at ...READ MORE

Jul 23, 2020 in Python by sahil
• 500 points
1,041 views
0 votes
1 answer

What is the difference between 2*2 and 2**2 in python?

2*2 is a multiplication operation output will ...READ MORE

Apr 12, 2020 in Python by Hari
2,327 views
0 votes
1 answer

how can i use the sum function in a python list?

If there is list =[1,2,4,6,5] then use ...READ MORE

Apr 23, 2020 in Python by anonymous
4,109 views
0 votes
1 answer

how do i get the list of all the keys in my dictionary?

my_dict = {'one': 'first', 'two': 'second', 'three': ...READ MORE

Sep 30, 2020 in Python by VJ_python
903 views
0 votes
1 answer

BeautifulSoup: How to get the text between p tag?

Find all the the paragraph tags and ...READ MORE

Apr 3, 2019 in Python by Esha
13,400 views
0 votes
1 answer

How to get permutations of list or a set in Python?

Permutation is an arrangement of objects in ...READ MORE

Jul 11, 2019 in Python by Neel
• 3,020 points
9,066 views
0 votes
1 answer

How to web scrape using python without using a browser?

Yes, you can use the headless mode. ...READ MORE

Apr 2, 2019 in Python by Yogi

edited Oct 7, 2021 by Sarfaraz 13,323 views
+1 vote
1 answer

Python: How to convert text to csv rows separated by a record separator?

Hi @Sumanth, try something like this: import csv with ...READ MORE

Dec 17, 2019 in Python by Pri
2,091 views
0 votes
2 answers

Finding local IP addresses using Python's stdlib

import socket s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s ...READ MORE

Mar 30, 2020 in Python by anonymous
3,192 views
0 votes
2 answers

How to define a class in python?

Class use the special word  class for declaration. ...READ MORE

Jun 6, 2020 in Python by anonymous
• 500 points
1,437 views
+7 votes
4 answers

What's the coolest thing you've ever done using Python?

Python is an extremely interesting language. you ...READ MORE

Nov 27, 2019 in Python by Tini
2,545 views
+1 vote
0 answers

how to match the following string without a regular expression in python

abc_pqr_0_114_004.xxx ab_pq_04_114.xxx READ MORE

Dec 17, 2019 in Python by Rajesh Babu
• 130 points
1,941 views
0 votes
1 answer

USING LIKE inside pandas.query()

If you have to use df.query(), the ...READ MORE

Jul 22, 2019 in Python by SDeb
• 13,300 points
8,317 views
+1 vote
0 answers

how can read text from website ??

from selenium import webdriver import time query = ('maps') if ...READ MORE

Jan 7, 2020 in Python by anonymous
• 130 points
1,040 views
0 votes
1 answer

How to find if a value exists in Pandas dataframe?

Try this:​ for name in df['Name']: ...READ MORE

Apr 8, 2019 in Python by Tina
12,837 views
0 votes
1 answer

How to run a Function in Spyder and check output?

You will see the output of the ...READ MORE

May 17, 2019 in Python by Omkar
• 69,220 points
11,038 views
+1 vote
1 answer

instead of using two for loops in python

This example might help: for x, y in ((a,b) ...READ MORE

Dec 24, 2019 in Python by Sumeir
1,451 views
+2 votes
1 answer

Create column for str,contain in pandas

Hi Juzar So if I am not wrong ...READ MORE

Jan 6, 2020 in Python by Kalgi
• 52,350 points
828 views
0 votes
1 answer

I am trying to view and preprocess a .mhd and .raw image types on jupyter notebook, but I am getting a syntax error.

Hey @tekle,  You cannot use a string in ...READ MORE

Nov 4, 2019 in Python by Payal
3,581 views
0 votes
1 answer

SyntaxError: Missing parentheses in call to "print".

The statement print "hello python" does not work in ...READ MORE

Jul 16, 2019 in Python by Umar
8,286 views
0 votes
1 answer

Is there a scanf() or sscanf() equivalent in python?

There is nothing as such for python. For ...READ MORE

Jul 30, 2019 in Python by Greg
7,689 views
0 votes
2 answers

How can I get the count of a list in Python?

n=[1,2,3,4,5,6,7,8,9] print(len(n)) =9 READ MORE

Dec 10, 2020 in Python by anonymous
1,679 views
0 votes
1 answer

flush parameter of print in Python

Usually all I/Os are buffered, meaning they ...READ MORE

Jul 30, 2019 in Python by Wajiha
• 1,960 points
7,482 views
0 votes
2 answers

How can I rename multiple files in a certain directory using Python?

import os from optparse import OptionParser, Option class MyOption ...READ MORE

Jul 29, 2020 in Python by The real slim shady
4,901 views
0 votes
4 answers

How to write a single program in python to print different '*' triangles?

If you want to use the same ...READ MORE

Jun 11, 2019 in Python by Likhith
9,491 views
+2 votes
2 answers

Google search using Python

import webbrowser search=input('Search: ') webbrowser.open('https:// ...READ MORE

Dec 25, 2019 in Python by Makhmudov
2,701 views
+1 vote
1 answer

How to save a bitmap or vector graphics image after creating a drawing with python's turtle module.

This worked for me: from Tkinter import * from ...READ MORE

Jul 6, 2019 in Python by Kyraa
8,422 views
0 votes
1 answer

Closest value and its index in a sorted list - Python

You can try this @Mahesh: lst = [ ...READ MORE

May 28, 2019 in Python by Sai
10,095 views
+5 votes
1 answer

Print the odd and even factors of a number in Python

x = int(input("Enter any number \n")) print("The factors ...READ MORE

Nov 19, 2018 in Python by Nabarupa
18,083 views
+1 vote
2 answers

How to automate image upload from my computer to site using python-selenium?

Hey, this code worked for me: image_path=os.path.abspath('.\\folder1\\subfolder2\file1.jpg') driver.find_element_by_id("Id of ...READ MORE

Aug 19, 2019 in Python by Rishi
6,422 views
0 votes
1 answer

How to input optional arguments in python command line?

Please use this code. if len(sys.argv) == 2: first_log ...READ MORE

Jul 11, 2019 in Python by Suri
7,899 views
0 votes
1 answer

Now able to open multiple windows: selenium.common.exceptions.WebDriverException: invalid session id

You have initialized driver only once and ...READ MORE

Apr 6, 2019 in Python by James
12,047 views
0 votes
1 answer

converting timedelta to float

Use the following piece of code: x1=datetime.timedelta(days=3000, seconds=0, ...READ MORE

Aug 8, 2019 in Python by Wajiha
• 1,960 points
6,625 views
0 votes
1 answer

Python Pandas: KeyError: False

The reason for this error is that ...READ MORE

May 8, 2019 in Python by Jimmy
10,517 views
+1 vote
1 answer

how do i get a optimal cutoff value(directly in the form of numeric) from roc curves?

The optimal CutOff value is the point ...READ MORE

Oct 17, 2019 in Python by Saira
3,445 views
0 votes
1 answer

Python error "'str' object has no attribute 'turtle' in Python turtle"

There is a syntax error. Change the ...READ MORE

Jul 9, 2019 in Python by Pallavi
7,769 views
0 votes
1 answer

how to convert date field into UTC format (2019-10-29T19:20:30.45Z)

Hey, I think this should do what ...READ MORE

Oct 29, 2019 in Python by Niharika
2,858 views
+1 vote
1 answer
0 votes
1 answer

Plot a pie-chart in Python in Matplotlib

Not sure which dataset you are using. ...READ MORE

Jul 22, 2019 in Python by Shri
7,095 views
+1 vote
0 answers

How to close a window, and then reinitialize it using PyQt

There is a button "btn_closeWin_and_reinit"  in the ...READ MORE

Jul 10, 2019 in Python by marceepoo
• 130 points

edited Jul 22, 2019 by Kalgi 7,621 views
+1 vote
0 answers

I have to write 2 triangles in one raw (python)

I have two triangles that has to ...READ MORE

Dec 4, 2019 in Python by מיקה
• 130 points
1,200 views
+3 votes
7 answers

How can I rename a file in Python?

yes, you can use "os.rename" for that. ...READ MORE

Mar 31, 2018 in Python by DareDev
• 6,890 points
20,360 views
0 votes
1 answer

Add header row in pandas dataframe while printing

Refer to this code: import pandas as pd col_name=['Name', ...READ MORE

Jul 5, 2019 in Python by Suri
7,705 views