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
-
-1
votes1
answer71
viewsHow can I just let my page access the file
I have a Flask page, and wanted to know how to make only my page access the files from Static I have a handling of files from Static (for image resizing):…
-
-1
votes1
answer45
viewsError trying to set the value of a class property
I’m a beginner in Python and I’m trying. I’m trying to understand the classes by creating some instances, but I get an error: Traceback (most recent call last) File "main.py", line 24, in…
pythonasked 5 years, 5 months ago Mauro Matsudo 1 -
-1
votes1
answer258
viewsClick on a Selenium div
I need to click the 'LIVE NOW' button on the 'https://www.academiadasapostasbrasil.com/' page. I made the following script, but it is giving an error, could not be scrolled into view. Below is the…
-
-1
votes2
answers611
viewsHow to overwrite a method
Hello I want to overwrite a method, here is the code of the sheet class: from Aluno import * class Bolsista(Aluno): __bolsa = 0.0 def renovarBolsa(self): print(f"Renovando bolsa de {self._nome}")…
-
-1
votes1
answer168
viewsHow to compare two lists of names in python?
Hello, all right? So I have two lists in pdf and I would like to get the names of the people who are on both lists. How would you do this in python? It would be better in another language?…
-
-1
votes2
answers457
viewsPool exercise in python
The question is, is there any way to make this program determining the percentage that each one will win according to how much you bet? and also how to know who was the biggest gambler, the middle…
-
-1
votes1
answer359
viewsConvert json to Dictionary
I’m trying to convert json the data into a dictionary. This json_test to be a Dict type but actually comes as a list type when I check with type(json1_data). import json json1_file =…
-
-1
votes1
answer84
viewsmodule 'Docker' has no attribute 'Client'
I’m using the Docker-py in version 3.7 of Python and when I try to execute the function that uses it an Attributeerror is returned My code: from django.shortcuts import render from django.http…
-
-1
votes2
answers50
viewsStrange error in For in Python
Hello, my friend. I’m making a very stupid mistake that I can’t even understand why it’s wrong. a = [1, 4, 5] b = [] for i in range(0,len(a)): c = a[i+1] b.append(c) The mistake is IndexError: list…
-
-1
votes2
answers66
viewsProblems with import and from/import command
I have a problem with my show. When I type "from Math import sqrt (or anything else", the Math library is not recognized by pycharm. Follows the code: from math import sqrt n = int(input('Digite um…
-
-1
votes1
answer72
viewsHow to use find in find_all result
When I execute a find_all, then I can’t use find in the outcome of this. Example: anuncios = soup.find_all('div', class_='txt-value') anuncios.find('p', class_='well') # Erro! But if I don’t…
-
-1
votes1
answer455
viewsCalculator in python
I had a problem trying to make a calculator in Python, the first error code in the "Userselectionselect" bool. I’m having second thoughts on how to declare a method in a dictionary. def…
-
-1
votes4
answers65
viewsI cannot print a list(vector)
I’m trying to make a decimal to binary converter follow the code: n = int(input('Insira um número decimal para conversão em binário ')) cont = [] aux = 0 while n > 1: if(n % 2 == 0):…
-
-1
votes1
answer72
viewsedit local variable out of function
Hello! How do I change a local variable from a function by external commands to the function? Example: Create the function def totalValue(type): try: valor = float(texto[0]) except: valor = 0 total…
-
-1
votes2
answers284
viewsConvert pandas dataframe column with string array (Python)
I have a data frame pandas in Python, in which one of the columns is bringing the values in an array(list). I would like to remove the brackets ([]), to convert into string. I have tried with strip,…
-
-1
votes1
answer438
viewsswap decimal separator in python
How do I change the decimal point separator to comma and then generate a graph? I used the following command, no error, but the chart continues with point as decimal separator import locale loc =…
-
-1
votes1
answer92
viewsWhat’s wrong with this Python code?
So I’m learning Python from the video course and I’m in class 9, Ex23, and I’m trying (in a mathematical way) to show the numbers divided to the person, only he’s wrong, and I have no idea what to…
-
-1
votes1
answer60
viewscreate a program that reverses the numbers using while, but my program will always ignore 0 at the end, how can I fix it?
def inverte(n): sequência = '' while n > 0: digito_invertido = n % 10 n //= 10 sequência += str(digito_invertido) return sequência def main(): n = int(input()) print(inverte(n)) if __name__ ==…
-
-1
votes1
answer245
viewsDictionary from list index
I have a list of names = [name1, name2, name3, etc] Each name is to have associated information such as address, phone, etc. I want to make a menu from the list index: print... 1 - Nome1 2 - Nome2 3…
pythonasked 5 years, 5 months ago douglas1alc 23 -
-1
votes1
answer940
views(IJ sequence 4) Why is my Python code giving Runtime error in the URI Online Judge?
I managed to run the program on my computer, however, when I submit to the online test cases it accuses 'Runtime error' and I am not able to circumvent the error. The problem is (Sequence IJ 4), the…
-
-1
votes2
answers194
viewsRaising fraction to power
I need to raise a number to a certain expoente, but I don’t know how to do it in case frações. For example, I know that to raise 2 to terceira potência, I must do 2**3. But if I want to raise 1/2 to…
-
-1
votes2
answers130
viewsShow Python words with 04 letters only
I’m learning Python and I’m doing an exercise, which is this one: Implement a program that asks the user for a list of words (i.e., strings) and then display on the screen, one per line, all…
-
-1
votes1
answer63
viewsFinite looping
I am transcribing from Java to Python a code to solve a Sudoku 4/4. When I test the code it doesn’t run and runs endlessly, apparently in one of the methods of the Artist class. Can someone help me…
-
-1
votes2
answers122
viewsTreating a string input when I hit enter without typing anything
Talk to the guys! If anyone can help me? When he asks me if I want to continue and I press enter without typing anything he lets me proceed. I wish that when I hit enter without typing anything it…
-
-1
votes1
answer133
viewsHow to make a macro that clicks in several places?
Hi, I’d like to know how to make one. exe that acts as a macro, whenever I press the ALT key it will perform mouse clicks at a certain position with shift pressed at the same time. It can be in any…
-
-1
votes4
answers975
viewsReturn a list from another list in Python
Given a list of integers and an integer n, returns another list, which contains all the numbers in the original list larger than n. I am unable to return the list I need. from typing import List def…
pythonasked 4 years, 1 month ago Marco Raad 43 -
-1
votes1
answer194
viewsHow to fix a wrong JSON?
Next, I’m developing a Python program that collects data from a JSON and transfers it to a CSV file. However, the server routine brings me a JSON with the wrong structure at some points of it, as in…
-
-1
votes3
answers243
viewsHow to save file without overwriting the previous python?
Hello, I am trying to save the name of the video files differently every time the program runs. currently it overwrites the name of the previous video. This is my current code: import cv2…
-
-1
votes1
answer25
viewsHow to use a custom tag within an IF tag?
Personal as I use a custom tag within an if tag? ex: {% if {%outraTag x y z %} == "Sucesso" %} my custom_field_tag @register.simple_tag def outraTag(x,y,z): r=x+y+z if r ==3: return "Sucesso" else:…
-
-1
votes1
answer275
viewsError in exchange for elements in the matrix
I’m trying to exchange two position elements in this matrix. After some changes, the elements begin to exchange among themselves in an apparently random pattern. Could someone identify me the…
-
-1
votes2
answers209
viewsFind values from a List and Replace in another list - Python
I am trying to search for elements of the A list in List B and replace it with another value if this element is found. How can I do this? A = ["Leao" , "Lobo" , "Largarto"] B = ["Cachorro" , "Leao"…
-
-1
votes1
answer26
viewsI cannot use functions and search for class attribute of an object
I’m not being able to call the attributes of the objects I create by the create_character function or activate the functions belonging to the class. I think when I try to assign the object in the…
-
-1
votes1
answer327
viewsChanging characters from a python message
I want to make a program that encrypts a message by the polar Zenit method, which consists of exchanging these letters among themselves, changing the text without the use of accents. I can already…
-
-1
votes1
answer170
viewsFunction to enable and disable Listener
Good afternoon guys, I have the following code that actually works perfectly. However I have an error when I click on "bt1" (boot button) my program crashes. However, it is working on the console.…
-
-1
votes2
answers840
viewsObject-oriented programming exercise in Python
I started studying object-oriented programming in Python this week and did an exercise but I don’t know if it’s right. I need someone to take a look at it to point out my mistakes because although…
-
-1
votes1
answer67
viewsreplace in numpy array
I have a phrase dataset and how do I use a replace in the numpy array EX x = array(['mais uma vez, o Sr. Costner arrumou um filme por muito mais tempo do que o necessário desse filme.])…
-
-1
votes1
answer24
viewsHow to display elements of specific sizes belonging to a list using lambda and filter functions?
In that code I wrote: lstNomes = ["casa", "google", "escola"] lstFiltro = list(filter(lambda x: x <= "5", lstNomes)) Is returning the empty array: [] I wanted to know how I get the element inside…
-
-1
votes1
answer74
viewsHow to ask the user to create an np.array vector?
I would like to know HOW is it possible to write a program that reads an array numpy vector np.array([]) user-created. In lists, for example, we do: n = int(input("Determine o número elementos da…
-
-1
votes1
answer52
viewsex de python help!
I caught it in an exercise. in the code you need to have a number n between 0 and 100 and in the next lines a variable representing how much money each one has and be printed the minimum amount for…
-
-1
votes1
answer82
viewsPrint prime numbers in range 0-N
Basically the program must check and display all prime numbers up to the entered value. I have already made a code that checks if it is prime or not (the check has to be done by a function), but I…
pythonasked 4 years, 1 month ago Victor Hugo 1 -
-1
votes1
answer53
viewsPYTHON cannot identify the error in the code
import pyautogui life50 = pyautogui.pixelMatchesColor(663, 306, (25, 195, 25)) if: life50 pyautogui.press('f1') else: pyautogui.screenshot('C:/Users/ANDRE/Desktop/Imagens') I am learning to code in…
pythonasked 4 years, 1 month ago André Esperança 11 -
-1
votes1
answer58
viewsutf-8 characters are replaced by " " in git bash
When I run my python code, if in that code you have a print, and that print receives a string with utf-8 characters, the letter is replaced by in the console. code: print('Olá') output ol▒…
-
-1
votes1
answer52
viewscopy text from pygame
Guys, I’ve tried everything and I can’t copy a text from a Pygame window. The code is as follows: import pygame screen = pygame.display.set_mode((800, 600)) pygame.font.init() font1 =…
-
-1
votes1
answer136
viewsHow to unify display windows?
Good afternoon, I’m using 2 cameras in a project, but when I run the code it opens in two different windows, I’m trying to make the two images open in the same window... Can someone help me? Thank…
-
-1
votes1
answer74
viewsHow to remove string characters
Hello I have the following code: lista_valores = ["20.000","2.000"] for valores in lista_valores: valor = valores.strip(".000") print(valor) And its result is: 2 2 But my goal is to get the values…
pythonasked 4 years ago user198451 -
-1
votes1
answer81
viewsHow to get the value of a Variable associated with a Checkbutton in Tkinter? - Python
How could I get the value contained in checkBtVar having as reference ckBt? for x in range(10): checkBtVar = Variable() ckBt = Checkbutton(root, variable=checkBtVar)…
-
-1
votes1
answer243
viewsNameerror: name is not defined for initialized vector, how to tidy?
I’m making a program to calculate a certain time, with a probability of something happening and going wrong, but I’m getting Nameerror: name 'tempo_ida' is not defined variable h is defined as 0.…
-
-1
votes1
answer24
viewsMy python merge PDF is not working
He’s showing error on line 3, says the file can’t be found, but I checked it all right, what can it be? import PyPDF2 f1 = open('documento1.pdf', 'rb') f2 = open('documento2.pdf', 'rb') pdf1 =…
-
-1
votes1
answer33
viewsWhat alternative do I use to solve the problem of the get() function not working
from tkinter import * def executar(): l1['text'] = t1.get() l2['text'] = t2.get() l3['text'] = t3.get() root = Tk() root.title('App') t1 = Entry(root) t2 = Entry(root) t3 = Entry(root) l1 =…
-
-1
votes1
answer254
viewsMulti-entry loop for list - Python
I have a list of several tuples inside, and within tuples various elements. I need to scan all tuples on the list to capture an element that is inside each of these tuples. How can I do this? The…