Most answered questions in Python

0 votes
1 answer

For Professional window GUI develepoment which python lib/module/framework is best?

HI, @Ganesh, Tkinter is one of the most ...READ MORE

Dec 24, 2020 in Python by Gitika
• 65,910 points
405 views
0 votes
1 answer

Getting error "AttributeError: 'Screen' object has no attribute 'title' on line 8"

Hey @TedTickles,  Replace  wn.update() with turtle.up ...READ MORE

Dec 24, 2020 in Python by Gitika
• 65,910 points
3,496 views
0 votes
1 answer

How to read a text file into a string variable and strip newlines?

You could use: with open('data.txt', 'r') as file: ...READ MORE

Dec 23, 2020 in Python by Gitika
• 65,910 points
449 views
0 votes
1 answer

Adding new column to existing DataFrame in Python pandas

Use the original df1 indexes to create ...READ MORE

Dec 23, 2020 in Python by Gitika
• 65,910 points
1,160 views
0 votes
1 answer

if/else in a list comprehension

You can totally do that. It's just ...READ MORE

Dec 23, 2020 in Python by Gitika
• 65,910 points
3,970 views
0 votes
1 answer

How to get list from pandas DataFrame column headers?

You can get the values as a ...READ MORE

Dec 23, 2020 in Python by Gitika
• 65,910 points
756 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
380 views
0 votes
1 answer

please what does print_details do in python?

Hi, @There, The print() function prints the specified message to the ...READ MORE

Dec 23, 2020 in Python by Gitika
• 65,910 points
402 views
+1 vote
1 answer

tensorflow is installed but theres an error while importing

Hi@Christlan, This problem is related to version. Follow ...READ MORE

Dec 22, 2020 in Python by MD
• 95,440 points
12,757 views
0 votes
1 answer

Why can't Python parse this JSON data?

Your data is not a valid JSON format. You ...READ MORE

Dec 20, 2020 in Python by Reshma
8,528 views
0 votes
1 answer

Delete column from pandas DataFrame in python

As you've guessed, the right syntax is del ...READ MORE

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

Getting the class name of an instance?

Have you tried the __name__ attribute of the class? ie type(x).__name__ will ...READ MORE

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

How to pad zeroes to a string?

Strings: >>> n = '4' >>> print(n.zfill(3)) 004 And for numbers: >>> ...READ MORE

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

Importing files from different folder in python.

By default, you can't. When importing a ...READ MORE

Dec 20, 2020 in Python by Nikita
3,566 views
0 votes
1 answer

How do you append to a file in Python?

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

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

Exception in Tkinter callback Traceback (most recent call last):

Hello, @R, As per the Beautiful Soup Documentation: AttributeError: 'NoneType' ...READ MORE

Dec 21, 2020 in Python by Gitika
• 65,910 points
19,305 views
0 votes
1 answer

Meaning of @classmethod and @staticmethod for beginner?

Example class Date(object): def __init__(self, ...READ MORE

Dec 18, 2020 in Python by Gitika
• 65,910 points
415 views
0 votes
1 answer

How can I count the occurrences of a list item?

If you only want one item's count, ...READ MORE

Dec 18, 2020 in Python by Gitika
• 65,910 points
492 views
0 votes
1 answer

How to remove an element from a list by index?

Use del and specify the index of the element ...READ MORE

Dec 18, 2020 in Python by Gitika
• 65,910 points
571 views
0 votes
1 answer

How can I print literal curly-brace characters in python string and also use .format on it?

You need to double the {{ and }}: >>> x = ...READ MORE

Dec 18, 2020 in Python by Gitika
• 65,910 points
461 views
0 votes
1 answer

How can I remove a trailing newline?

Try the method rstrip() (see doc Python 2 and Python 3) >>> 'test ...READ MORE

Dec 18, 2020 in Python by Gitika
• 65,910 points
651 views
0 votes
1 answer

Why is reading lines from stdin much slower in C++ than Python?

tl;dr: Because of different default settings in ...READ MORE

Dec 18, 2020 in Python by Nikita
1,012 views
0 votes
1 answer

HI Mr / Mrs I have problem with my jupiter notebook when i try to learn Your video about Machine Learning. Can You help me please ?

Hi@Herlambang, I think you have a 32-bit system. ...READ MORE

Dec 18, 2020 in Python by MD
• 95,440 points
547 views
0 votes
1 answer

How to print colored text in Python?

This somewhat depends on what platform you ...READ MORE

Dec 17, 2020 in Python by Gitika
• 65,910 points
1,267 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
372 views
0 votes
1 answer

How to find current directory and file's directory?

To get the full path to the ...READ MORE

Dec 17, 2020 in Python by Gitika
• 65,910 points
2,258 views
0 votes
1 answer

“Least Astonishment” and the Mutable Default Argument

Actually, this is not a design flaw, ...READ MORE

Dec 17, 2020 in Python by Gitika
• 65,910 points
336 views
0 votes
1 answer

How to catch multiple exceptions in one line in python?

From Python Documentation: An except clause may name multiple ...READ MORE

Dec 17, 2020 in Python by Gitika
• 65,910 points
4,843 views
0 votes
1 answer

How can I add new keys to a dictionary?

d = {'key': 'value'} print(d) # {'key': 'value'} d['mynewkey'] = ...READ MORE

Dec 17, 2020 in Python by Gitika
• 65,910 points
442 views
0 votes
1 answer

Accessing the index in 'for' loops?

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

Dec 16, 2020 in Python by Gitika
• 65,910 points
393 views
0 votes
1 answer

How do I check whether a file exists without exceptions?

 It's safer to use a try around the attempt ...READ MORE

Dec 16, 2020 in Python by Gitika
• 65,910 points
495 views
0 votes
1 answer

What does the “yield” keyword do?

To understand what yield does, you must understand what generators are. ...READ MORE

Dec 16, 2020 in Python by Gitika
• 65,910 points
349 views
0 votes
1 answer

ImportError: No module named sklearn.cross_validation

Regarding your query, it must relate to ...READ MORE

Dec 16, 2020 in Python by Nikita
2,877 views
0 votes
1 answer

Error: IndexError: list index out of range and python

IndexError The IndexError is raised when you attempt to retrieve ...READ MORE

Dec 16, 2020 in Python by Gitika
• 65,910 points
1,469 views
0 votes
1 answer

how easy is yaml to work with in python compared to json?

Hi, First thing YAML and JSON are not ...READ MORE

Dec 16, 2020 in Python by MD
• 95,440 points
639 views
0 votes
1 answer

python pycharm is not proper working

Hi, @Webinar, Are you getting any kind of ...READ MORE

Dec 14, 2020 in Python by Gitika
• 65,910 points
282 views
0 votes
1 answer

i am getting this error "TypeError: tuple indices must be integers or slices, not Database"

Hi, @Shabaj, Regarding your query, I hope this ...READ MORE

Dec 10, 2020 in Python by Gitika
• 65,910 points
911 views
0 votes
1 answer

There are some Error so resolve quickly

Hi@Aditya, It is working fine in my python ...READ MORE

Dec 9, 2020 in Python by MD
• 95,440 points
336 views
0 votes
1 answer

How to find local IP addresses using Python's stdlib?

Hello @kartik, Try this out: import socket s = socket.socket(socket.AF_INET, ...READ MORE

Dec 8, 2020 in Python by Niroj
• 82,880 points
766 views
0 votes
1 answer

How can I open multiple files using “with open” in Python?

Hello @kartik, Just replace and with , and you're done: try: ...READ MORE

Dec 8, 2020 in Python by Niroj
• 82,880 points
530 views
0 votes
1 answer

How can I use Python to get the system hostname?

Hello @Kartik, Use socket and its gethostname() functionality. This will get the hostname of ...READ MORE

Dec 8, 2020 in Python by Niroj
• 82,880 points
1,444 views
0 votes
1 answer

How do I change the working directory in Python?

Hello @kartik, use os.chdir like this: os.chdir("/path/to/change/to") By the way, if you ...READ MORE

Dec 8, 2020 in Python by Niroj
• 82,880 points
604 views
0 votes
1 answer

How to create a GUID/UUID in Python?

Hello @kartiK, If you need to pass UUID ...READ MORE

Dec 8, 2020 in Python by Niroj
• 82,880 points
1,715 views
0 votes
1 answer

How to make a password validator without the use of the any()?

Hi, @There, Regarding your query I would suggest ...READ MORE

Dec 8, 2020 in Python by Gitika
• 65,910 points
460 views
0 votes
1 answer

How do I detect whether a Python variable is a function?

Hello @kartik, You can import isfunction from the inspect module. >>> from inspect ...READ MORE

Dec 7, 2020 in Python by Niroj
• 82,880 points
436 views
0 votes
1 answer

How to get an absolute file path in Python?

Hello @kartik, Try this out: >>> import os >>> os.path.abspath("mydir/myfile.txt") 'C:/example/cwd/mydir/myfile.txt' Also ...READ MORE

Dec 7, 2020 in Python by Niroj
• 82,880 points
603 views
0 votes
1 answer

How to check if type of a variable is string?

Hello @kartik, You can do: var = 1 if type(var) ...READ MORE

Dec 7, 2020 in Python by Niroj
• 82,880 points
414 views
0 votes
1 answer

How to print an exception in Python?

Hello @kartik, For Python 2.6 and later and ...READ MORE

Dec 7, 2020 in Python by Niroj
• 82,880 points
481 views
0 votes
1 answer

'NoneType' object has no attribute 'text

Hello @Muhammad Umer, As per the Beautiful Soup Documentation: AttributeError: ...READ MORE

Dec 7, 2020 in Python by Niroj
• 82,880 points
26,692 views