Most voted "python" questions
Python is a dynamic and heavily typed programming language whose design philosophy emphasizes usability. Two similar but incompatible versions of Python are in use (2 and 3). Please mention the version you are using when asking a question about Python.
Learn more…8,642 questions
Sort by count of
-
-2
votes1
answer35
viewsHow to set specific directory for Render_template flask?
I am rendering an html report using the Flask render_template. By default render_template renders what is in the template folder, however, I need to change to make the directory another. I tried to…
-
-2
votes2
answers39
viewsTaking values from a for
Very simple doubt indeed. I have the following list: fruits = {"apple":"123", "banana":"456", "cherry":"789"} for fruit in fruits: print(fruit) How do I stop in my return appear the numbers of each?…
-
-2
votes1
answer92
viewsSale of automated stamps (Python)
Good afternoon, sera could help me with a python problem? I need: (1) Calculate the amount of 50 and 20 cent stamps to be purchased by the user. (2) Tip 2: To figure out how to calculate the number…
-
-2
votes1
answer35
viewsEarly programming
Make a program that shows on the screen a multiple choice question, and that, from the user’s answer, show on the screen whether he hit or not. Unable to develop this question, my code became like…
-
-2
votes1
answer23
viewsPython Basehttprequesthandler - How to insert correct image path
When I create a Web application in python, but without using Frameworks, just using the Httpserver and Basehttprequesthandler classes, how do I insert an image? That is the code:…
pythonasked 3 years, 6 months ago Paulo Luvisoto 907 -
-2
votes2
answers113
viewsHow to use alphabet range in python?
I am trying to make a program that makes the letters of the alphabet in triangle type so the user enters with an integer number and the result is displayed in triangle form. 7: A BB CCC DDDD EEEEE…
-
-2
votes1
answer617
viewsError reading csv file in Python
When reading a file .csv in python generates the error below. The file is too big and I can’t open it. Someone knows how to proceed and what error is this ? import pandas as pd dados =…
-
-2
votes1
answer36
viewsHow to convert the expires token to a date
Hello, I am starting my walk with Python and JWT, I am authenticating myself in an external API and I have as return the Token and the "expires_in", however the value comes in a format I need to…
-
-2
votes1
answer56
viewsSimple Python gain experience system
I am having some doubts, I am creating an RPG by commands, simple thing to put in practice what I am learning. The truth is that I caught in a situation, I want to create a command in which the…
pythonasked 5 years ago Rodrigo Moreira 11 -
-2
votes2
answers100
viewsWhat is wrong with python below? Any suggestions for another solution?
Problem: Having a 5 5 matrix filled with random (real) values between 0 and 99, show which is the second highest value existing in the matrix. Can’t use numpy or similar. My solution: n=2 def…
-
-2
votes1
answer31
viewsPandas - Exhibition after groupby
How do I make sure the Offices column does not go blank, thus repeating the office name? mun_df = planta_df[['Empresas', 'Escritórios', 'Municípios', 'Estados']] mun_df = mun_df.groupby(['Empresas',…
-
-2
votes1
answer71
viewsCheck if e-mail has loophole through have I been Pwned (Selenium/Python)
Good afternoon! I’m using Selenium for automated testing. The goal is to verify, through a list of institutional emails, if the email is in some loophole and send a standard email requesting…
-
-2
votes1
answer56
viewsPerform function according to dictionary key
I want the user to choose an option and according to the chosen option the system performs a specific function. I wanted a more generic solution without a lot of if, elif and else. I thought of…
-
-2
votes1
answer61
viewswebdriver.get(url) with problems accessing B3 website consistently
I’m trying to access the B3 website using Selenium, but I can’t consistently access a specific URL. Sometimes it loads normally, but others the page I try to open keeps loading for a while and then…
-
-2
votes1
answer93
viewsKeep a larger number in a Python division
@Edit Good evening, I’m having a problem in this code below It performs two multiplication operations a * h = X b * C = Y so far so good, but for example, the value of X is less than the value of Y,…
-
-2
votes1
answer43
viewshow to create a function that has three parameters, but only use two of each of these parameters in python
I need to create a function that calculates the trigonometric ratios between the sides of a rectangular triangle. The function should receive three parameters: opposite cathode, adjacent cathode and…
-
-2
votes1
answer46
viewsDoubt about python/basic algorithms
I am making a personal challenge,develop the smallest program possible to manage a fibonati sequence and that shows the fi(gold number). Most recent code : nf = int(input("Quantos numeros da…
-
-2
votes1
answer1278
viewsHow to resolve "'int' Object is not subscriptable" error?
I would like help in def below, the error appears as: Typeerror: 'int' Object is not subscriptable def editar(mercadoria): print("\nEditar mercadoria: \n") produto = input("\nDigite o produto a ser…
-
-2
votes1
answer37
viewsWhen use Reverse() the output is "None"
continua = 'p' valores = [] cinco = 5 while continua != 'n': valores.append(int(input('Digite um numero'))) continua = input('Deseja continuar? [S/N]').lower().strip()[0] if continua =='n':…
pythonasked 3 years, 4 months ago luizotavio 7 -
-2
votes1
answer49
viewsHow to get rid of a vertical line in the Pycharm editor
to incindo agr in Python and to using pycharm, and soon after opening the editor and has a vertical line, HOW I’ll get rid of that?
-
-2
votes1
answer40
viewsHow to split large numbers without python abbreviating it?
Whenever I try to do calculations in python with large numbers, it ends up abbreviating the result. For example: a = 8682372684397235357614080000 b = 86400 c = a/b print(c) 1.0049042458793097e+23…
-
-2
votes1
answer178
viewsProblem when deleting a number from a list!
After drawing a number from a list, I need to delete this number from my list. but the message "list index out of range" appears. My error is in the if line. or is there a better way to delete that…
-
-2
votes1
answer53
viewsHow to make the Join() method work for each word from multiple lists within another list
I had done something like this for the even and odd list for the question asks: read several words (one by one) and concatenate in two (2) texts the words read, as per: TEXT 1: All PAR-Sized Words;…
-
-2
votes2
answers29
viewsWhen trying to extract a PDF using Python Textract, returns an error
I am using the Python library, which is Textract, to extract text from a PDF file, but is getting an error while running the script. Below is the script and the error returned in the console. import…
-
-2
votes1
answer39
viewsHow to extract information from a python request
import requests from requests.structures import CaseInsensitiveDict url = f"http://localhost/teste.php" headers = CaseInsensitiveDict() headers["Accept"] = "*/*" resp = requests.get(url,…
-
-2
votes2
answers50
viewsTake a string snippet between two characters
I have some information I need that comes in the following format: <http://informacaoquepreciso.com.br> "rel"="next" In this case what I need to pick up only the text that is within the <…
-
-2
votes1
answer61
viewsGet pathlib file name only
I currently have the following code: from pathlib import Path for file in Path("resources/maps").glob("*.json"): print(file) Which returns: resources\maps\map1.json resources\maps\map2.json…
-
-2
votes1
answer62
viewsError while running Selenium
Buddy, good night! I’m starting my walks in programming, and I always come here to ask some questions, but today I made my registration here to ask for your help. These days I attended an immersion…
-
-2
votes1
answer41
viewsI am making a program in python, and Return is not working
def primo(b, d): d = 0 c = 1 x = 0 while c < b+1: if b % c == 0: x += 1 c +=1 if x == 2: d = 1 return d d = 0 c = [] b = 3 a = int(input ("coloque o número que você quer que seja 'fatorado': "))…
-
-2
votes3
answers67
viewsHow to not execute lines of code when the name is not in the list
Good evening! I’m starting Python programming. I have this exercise (book) that I changed to have more user interaction. When we insert a string that is not in the list, it presents the 'menu'. How…
-
-2
votes1
answer55
viewsDoubt about a question I’m trying to solve I have this following code in python:
temperaturas_c = [('Argentina', 20), ('Brasil', 30), ('Estados Unidos', 28)] I have a list that contains the names of the countries and their temperature in Celsius in a tuple, I would like to…
-
-2
votes1
answer50
viewsExtract text from a python string
I have the following difficulty. I have a df with several columns and one of them is Description. In the middle of this description I have the product code and would like to extract this information…
-
-2
votes1
answer41
viewsLoop for with isinstance() command does not work as expected
The first time I printed the variable "b", I expected the number 6 to appear, but a 0 is returned. However, outside the function it works perfectly. How to make this specific code work within a…
-
-2
votes1
answer35
viewsPython - Error import pandas
People I’m in trouble when I try to use pandas in my project, see this mistake: File "c:\Users\jua2544825\Desktop\front_reembolso\main.py", line 10, in <module> from pandas import read_csv as…
-
-2
votes0
answers36
viewsFor loop taking only the first df item, and xpath not returning value
I think the loop only takes the first number of the df print(span) appears 2, and xpath is returning empty in print(lucro_el), tried with the print(len(lucro_el)) and the answer was 0 span_index =…
-
-2
votes0
answers9
viewsAttributeerror: 'Outstream' Object has no attribute 'buffer' in weasyprint module in Python
Importing the weasyprint module into python gives the following error: AttributeError Traceback (most recent call last) <ipython-input-3-5c808e9d68b5> in <module>() 2 import pandas as pd…
-
-2
votes0
answers28
viewsRecursive function to return largest element in a list
Recursive function that receives a lista and return the highest value from that list. def maior(lista): maior=0 if len(lista)==0: return lista elif len(lista)==1: return lista else: for i in lista:…
-
-2
votes0
answers29
viewsImport library automatically
Is there any extension of Visual Studio Code that when using a library in the code, it is automatically imported? Ex: from PySimpleGUI import PySimpleGUI as sg layout = [ [sg.Text('Teste')] ] I…
-
-2
votes1
answer63
viewsHow to break a line in the print of a python list?
My question is how to do the line break in a list print in Python. I need to print the code working. Except the names on the list are getting too long. Every 10, the winner gets 1 coupon, so if he…
-
-2
votes1
answer41
viewsHow to create a class that contains a list of objects of a parent class?
I need to create a person class that will have attributes (name, age) and a group class that will contain a list of objects of the person class. However I do not know how to do the second class...…
-
-2
votes1
answer27
viewsHow do Return only return first index from the list, Python3.9?
I need to get my Return to return all the values that are on my list, all in one function. But always returns only the first value.…
-
-2
votes1
answer40
viewsDeleting item from list (dictionary) - Python
I own a dictionary called alunos, that works by relating a student’s name to a list of grades, for example: alunos = {'Fulano': [2, 4, 10, 5.5]} I need to delete the first value from this list,…
-
-2
votes1
answer26
viewsGooglesearch library does not work
I created a tool (python 3.7) a while ago using the library Googlesearch and worked normally, I decided to use it today and noticed that is giving problem in the library. Code: from googlesearch…
pythonasked 4 years, 10 months ago user160936 -
-2
votes0
answers22
viewsUncertainties in linear regression coefficients in Python
How to find uncertainties in the coefficients of a linear regression using the function polyfit() of Numpy or the function curve_fit() of Scipy? I know how to find the coefficients, but I would like…
-
-2
votes1
answer31
viewsHow to return the indices that an element appears in a tuple?
**Write a function called 'positions' that you take as input arguments a tuple and an item, and returns a list containing all the indexes in which the item appears on tuple. If the item does not…
-
-2
votes2
answers158
viewsHow to reduce the amount of Elif
I’m starting in python and the current project (which is to apportion printers) has a lot of Elif, have any method I can reduce this in python? already I thank you. This and the current code: for i…
-
-2
votes0
answers12
viewsHow do I list only pairs with USDT, Eliminating pairs with UPUSDT AND DOWNUSDT?
import pandas as pd data = pd.read_json('https://api.binance.com/api/v1/ticker/allPrices') print(data)
-
-2
votes0
answers22
viewsI don’t know how to do it, somebody help me
You have to create a program that answers the following calculation n=(vc * 100) / (d * pi) 3x and each time you calculate, use the following lists: vc = [110, 220, 330] and d = [20, 30, 45],…
-
-2
votes1
answer889
viewsConvert string to json [Python]
I have a case where I have a json(is like clob) in the database and I want to use it to make a post request and everything by python, but I have a problem at the time of converting this string to…
-
-2
votes0
answers13
viewsHow to make the code not automatically shorten a text
import pandas as pd df = pd.read_fwf(r'C:\Users\gabri\Downloads/tokens-padrao.txt') gambiarra = str({f'{df}'}) gambiarra = gambiarra.replace('{', '') gambiarra = gambiarra.replace('}', '') gambiarra…
pythonasked 3 years, 2 months ago Fusquinhaw 1