Trending questions in Python

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,962 views
0 votes
0 answers

Why do I get double spaces if the user has no middle name?

I'm trying to learn Python and this ...READ MORE

Jan 27, 2021 in Python by Benn

edited Mar 4, 2025 292 views
0 votes
1 answer

How to get the SQL from a Django QuerySet?

Hello @kartik, Try this in your queryset: print my_queryset.query For ...READ MORE

Jun 23, 2020 in Python by Niroj
• 82,800 points
9,660 views
0 votes
0 answers

How do you check if the current user is the same as a foreign key in a model?

I have a model called Tribe which ...READ MORE

Jan 26, 2021 in Python by Andrija

edited Mar 4, 2025 295 views
+1 vote
2 answers

Error:Django gives Bad Request (400) when DEBUG = False

Tried this and it resolved all my ...READ MORE

Sep 25, 2020 in Python by Agaba
7,532 views
+1 vote
1 answer
0 votes
0 answers

What is this python script doing??

READ MORE

Jan 26, 2021 in Python by patrick

edited Mar 4, 2025 287 views
0 votes
1 answer

Remove final character from string

Simple: st = "abcdefghij" st = st[:-1] There is ...READ MORE

Jan 5, 2021 in Python by Gitika
• 65,730 points
1,131 views
0 votes
0 answers

what is this doing?

READ MORE

Jan 26, 2021 in Python by patrick

edited Mar 4, 2025 272 views
0 votes
1 answer

Error in jarvis project (get url)

Hey, @Zodarlxx, Could you please post your error ...READ MORE

Dec 30, 2020 in Python by Gitika
• 65,730 points
1,402 views
0 votes
0 answers

Weight calculation for Fico score

how could i calculate weight for fico ...READ MORE

Jan 23, 2021 in Python by Noman
• 220 points

edited Mar 4, 2025 343 views
0 votes
1 answer

How to return None if Dictionary key is not available

Hello @kartik, You can use dict.get() value = d.get(key) which will ...READ MORE

Apr 30, 2020 in Python by Niroj
• 82,800 points
11,865 views
0 votes
1 answer

How to update Django session variable in javascript?

Hello @kartik, You can do this via Ajax. ...READ MORE

Jul 30, 2020 in Python by Niroj
• 82,800 points
7,887 views
0 votes
1 answer

ModuleNotFoundError: No module named 'pymongo'

Hi@akhtar, It seems you don't have a Pymongo module ...READ MORE

Jun 26, 2020 in Python by MD
• 95,460 points
9,360 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,730 points
1,567 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,800 points
2,217 views
0 votes
0 answers

I can't locate class name in flikart samsung mobiles where i want to list all the samsung mobile price?

<div class="_30jeq3 _1_WHN1">₹14,999</div> .I can't locate the ...READ MORE

Jan 21, 2021 in Python by Monisha

edited Mar 4, 2025 356 views
0 votes
0 answers

joining two images reading from one folder

Hi, i am trying to generating joined ...READ MORE

Jan 3, 2021 in Python by shapna
• 120 points
1,081 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,730 points
1,672 views
0 votes
2 answers

Python error "TypeError: Can't convert 'int' object to str implicitly"

A TypeError can occur if the type ...READ MORE

Feb 5, 2020 in Python by lovelmark
• 160 points
1 flag 20,781 views
0 votes
1 answer

Explain split() and join() functions in Python?

Hey, @Roshni, You can use split() function to split a ...READ MORE

Jun 23, 2020 in Python by Gitika
• 65,730 points
9,406 views
0 votes
1 answer

I am trying to install os-win on my python 3.8. But I end up with the following error:

I have the same issue and is ...READ MORE

Sep 6, 2020 in Python by anonymous
9,731 views
0 votes
1 answer

invalid literal for int() with base 10 in python

Hello, You can try this simple code: def getSum(n): ...READ MORE

Nov 23, 2020 in Python by Niroj
• 82,800 points
2,815 views
0 votes
1 answer

How to combine two or more querysets in a Django view?

Hello @kartik, Concatenating the querysets into a list ...READ MORE

Aug 3, 2020 in Python by Niroj
• 82,800 points
7,619 views
0 votes
1 answer

How do I build a website with referral link on Django?

simple solution.. import hashlib Refferal(Model): user ...READ MORE

Nov 12, 2020 in Python by Gitika
• 65,730 points
3,201 views
0 votes
1 answer

Installing PIL with pip

Install Xcode and Xcode Command Line Tools ...READ MORE

Sep 11, 2020 in Python by FogleBird
5,855 views
0 votes
1 answer

Error:'QuerySet' object has no attribute 'remove'

Hello @kartik, You could do this: import itertools ids = ...READ MORE

Aug 12, 2020 in Python by Niroj
• 82,800 points
7,130 views
0 votes
1 answer

How to divide one number to another multiple times, untill it will be about 0?

You can do something like this:  while num ...READ MORE

Nov 10, 2020 in Python by Gitika
• 65,730 points
3,238 views
0 votes
1 answer

How to get all links and all elements that are clickable on a page of system dynamically?

Hello, You can do it by using find_elements_by_xpath() driver ...READ MORE

Aug 27, 2020 in Python by Niroj
• 82,800 points
6,456 views
0 votes
1 answer

AttributeError: 'numpy.ndarray' object has no attribute 'append'

Hi@Nilesh, You have created two empty lists. And ...READ MORE

Aug 11, 2020 in Python by MD
• 95,460 points
7,182 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,730 points
1,926 views
0 votes
1 answer

Error:Traceback (most recent call last): File "< stdin >", line 1, in ImportError: cannot import name 'path'

Hello @kartik, You need Django version 2 pip install ...READ MORE

Aug 5, 2020 in Python by Niroj
• 82,800 points
7,386 views
0 votes
1 answer

pip install mysql-python fails with EnvironmentError: mysql_config not found

It seems mysql_config is missing on your ...READ MORE

Dec 4, 2020 in Python by Gitika
• 65,730 points
2,133 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,730 points
1,271 views
0 votes
0 answers

How can i dynamically mapp models id's in django

ysql> select * from exampleapp_author; +------+-------------------------+---------------+ | id    ...READ MORE

Jan 16, 2021 in Python by anonymous

edited Mar 4, 2025 281 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,730 points
1,484 views
0 votes
1 answer

Error: wn = trtl.Screen() AttributeError: 'Turtle' object has no attribute 'Screen

Hi, @There, It requires a very simple hack ...READ MORE

Nov 3, 2020 in Python by Gitika
• 65,730 points
3,427 views
0 votes
0 answers

File "<ipython-input-30-eae839ba8312>", line 11 d=dist(queryPoint,X[i]) ^ IndentationError: expected an indented block

for i in range(m):     d=dist(queryPoint,X[i]) &nb ...READ MORE

Jan 15, 2021 in Python by anonymous

edited Mar 4, 2025 278 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,730 points
1,522 views
0 votes
1 answer

How to import an image into a csv file using python?

I am sure you are aware CSV ...READ MORE

Jun 25, 2020 in Python by Bhanu Kumar
9,030 views
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,730 points
1,163 views
0 votes
1 answer

ImportError: cannot import name 'API_KEY' from 'forwarder'

The AWS package in PyPI is not AWS's official ...READ MORE

Nov 6, 2020 in Python by Gitika
• 65,730 points
3,207 views
0 votes
1 answer

How to find the index of an item in a list?

One thing that is really helpful in ...READ MORE

Dec 3, 2020 in Python by Gitika
• 65,730 points
2,038 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,730 points
1,320 views
0 votes
1 answer

Please Help me About this Pygame Error installing on pip

Hi, @Micheal, Download pygame‑1.9.3‑cp37‑cp37m‑win_amd64. While if you have a 64-bit ...READ MORE

Oct 12, 2020 in Python by Gitika
• 65,730 points
4,321 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,460 points
1,451 views
0 votes
1 answer

Hey Does anybody know how to fix the unexpected indent error?

Hello, @Aarohan, As the error message indicates, you ...READ MORE

Dec 28, 2020 in Python by Gitika
• 65,730 points
946 views
0 votes
0 answers

I can't get accurate value in dictionaries in django

Whenever I try to print the dictionaries ...READ MORE

Dec 25, 2020 in Python by Mohamed
• 170 points
1,061 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,730 points
1,320 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,730 points
1,102 views