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
-
0
votes1
answer54
viewsFor i uses only the last variable - Python
Good morning! I am with a project that I am improving and would like to make a For i to run all variables within the project, but when running it applies the project only to the last variable. Code:…
-
0
votes1
answer25
viewsMy inserts are not being saved
I installed a postgre cluster using pgpool in Docker containers, https://github.com/paunin/PostDock. I can connect to pgpool and make insertions and other normal sql commands. psql monkey_db -h…
-
0
votes1
answer1158
viewsError: module import emoji no found
I am practicing a python class and need to download the emoji library so that the program after run prints the emoji that the user typed. However, when executing, it says that the library is not…
pythonasked 6 years, 2 months ago bruno afonso 1 -
0
votes2
answers3007
viewsIdentify the day of the week of a given date
One of the questions of a college task is giving work to the whole class, so far no one has been able to answer question 4. A friend of mine tried with this code, but it doesn’t work right, because…
-
0
votes1
answer548
viewsIndexerror: list index out of range Python
I’m getting the following error: IndexError: list index out of range My code: conts = conts[0] if imutils.is_cv2() else conts[1] How can I correct this mistake? Complete code…
-
0
votes1
answer123
viewsLimit items in a dictionary
I am trying to analyze data from a research of own authorship, the files are already tabulated in .xlsx. format I use openpyxl. My intention at that time is to take the state of the participants +…
-
0
votes1
answer739
viewsUpdate a value within a function
I am starting in Python and need help to create the following function: ESQUERDA = -1 DIREITA = 1 CANHAO = 'A' EXPLOSAO = '*' def moveCanhao(direcao, matriz): ''' int, (matriz) -> bool Recebe um…
-
0
votes1
answer118
viewsPython GIF API
is my doubt and the following I have this script where I type the name of the gif I want and it returns me several type of url of the size(width,height) of the randomly drawn gif, I wanted it to…
-
0
votes0
answers173
viewsHow to get the <span> text? but when you have an <img> in that <span> error!
The following code picks up the span, but if he has a img presents an error. user = driver.find_element_by_xpath('//span[@title = "{}"]'.format(names)) user.click() My system picks up the title of…
-
0
votes1
answer674
viewsReceive a Long String with esp 01
I have a esp 01(Wi-fi module) connected in my Arduino on port 2 and 3(TX RX), I can send a large String, but when I receive I can only receive at most 32 characters, here is the code of my Arduino:…
-
0
votes2
answers6760
viewsMath Domain error in PYTHON
I know that if the root is less than zero it will not exist, but, something happens, even if I implement that if the delta value is less than zero is to write the error it still continues showing…
pythonasked 6 years, 6 months ago Gabriel Menezes 113 -
0
votes2
answers107
viewsHow do you inherit a pygame class?
When I run this code (this is the current entire code, ie only 3 lines): import pygame class sp(pygame.sprite): pass I get: Typeerror: module() takes at Most 2 Arguments (3 Given) I would like to…
-
0
votes2
answers1690
viewsChange Python string
I’m making a program to sort the numbers entered (I can’t just use a sort algorithm), searching saw that it is not possible to change strings in python, is there any way to do this? Or maybe use…
-
0
votes1
answer249
viewsHow to inform parameters to the parent class initializer with Python?
Hello, I’m making inheritance in python and I’m encountering the following error: Typeerror: __init__() takes Exactly 2 positional Arguments (4 Given) class A(): def __init__(self,a,b): self.a = a…
-
0
votes0
answers20
viewsVery slow M2M loading on Django
In some tables I use Many to Many, and as the bank has been growing its loading time is increasing (which is obvious), I got an alternative to the load, which is raw_id_fields, however it does not…
-
0
votes1
answer57
viewsRemove index spaces in a list
In the list below, I want to print only the gender of each index, which, in fact, I can, but as you can notice there are 4 lists that are without definition of gender, which causes, when printing…
-
0
votes1
answer70
viewsError in list conversion in Python
I have the following problem: lista1 = [3,4,5] list(map(lambda x: x**3, lista1)) Made that mistake: TypeError Traceback (most recent call last) <ipython-input-14-5e26f3f7b396> in…
pythonasked 6 years, 2 months ago Rafael Silva 1 -
0
votes1
answer424
viewserror in Math.sqrt
I’m using the module Math in python, and I came up with a problem, when using Math.sqrt for the 75 root, it returns me 7.5, even using float(), and the root is around 8.66 How can I fix this problem…
-
0
votes1
answer3769
viewsHow to select a field and type in it with Selenium?
I’m trying to select the input field but I’m not getting it. Error Traceback (most recent call last): File "C:\Users\Pichau\Desktop\Teste.py", line 7, in <module> elem.clear() File…
-
0
votes1
answer41
viewsHow to recognize the selected entry
I have two data entries (password.entry,id.entry) and I want to make the program recognize which of these fields is clicked and enter the value that is inside a button in this selected field.…
-
0
votes2
answers487
viewshow can I make a simple python Russian roulette
I wanted a simple scrip where it counts up to 6 using while or another repeating method. And there’s going to be a list with 5 failed and 1 died and he’s counting to 6 drawing this list and when he…
-
0
votes1
answer4801
viewsHow to encrypt password with Python
I need to encrypt password using Python, from what I saw in examples in PHP, they use a "module" that encrypts the password and which in theory does not decrypt, to validate the password they…
-
0
votes1
answer30
viewsHow to run Taiga.io on my computer using Nginx
I’m trying to spin the Taiga. on my computer. All part of backend works normally, but when I try to access the URL exemplo.com, doesn’t work. I’m using:…
-
0
votes1
answer180
viewsProblem when inserting rounds in stone game , paper and scissors
Good morning, I’m not able to implement a system of rounds in this game , the rounds must change when the player’s Mao is empty. , what happens now is that when the player and player list empty the…
-
0
votes1
answer353
viewsHow to capture events in Python?
I would like to capture the user-clicked keys through Ironpython. I understand a little C#, but I don’t understand how I would do it in Python. Code: import clr…
-
0
votes1
answer1839
viewsPython - Error in using import, module --- has in attribute
Hello, I’m writing the code for a university project, but when I try to import dependencies to some files, from Error. I created some package’s that have files that have dependencies, but they don’t…
-
0
votes1
answer84
viewsDoubt Python libraries
Good afternoon! I am new to development using the Python language, I would like some good library tips to be studying and mainly one aimed at "manipulating websites" (currently I only know the…
-
0
votes1
answer53
viewsPass several attributes on Django
My question is as follows. I am starting my studies in Jango and find a problem. I have a function in my view with the following excerpt def saldo_total(request): receitas =…
-
0
votes0
answers49
views"None" instead of [1,1,1,1]
I’m making a problem that works like this: For example, suppose a team of 4 telemarketing vendors should make 6 calls, the times being 5, 2, 3, 3, 4, 9. As initially no vendor is busy, the first…
-
0
votes1
answer836
viewsExport a dictionary to file . txt
Hello. I would like to know how I export a dictionary to a file. txt. and how to import the data that is in the.txt file into the dictionary in the program. When I care, the dictionary gets all…
-
0
votes2
answers99
viewsinvalid.syntax appears when the program is run
I’ve tried to put palavra = '' and the same error keeps appearing: lista = [] i = 0 while (palavra != 'Sair') or (palavra != 'sair'): i += 1 palavra = str(input('digite alguma palavra: ')…
-
0
votes2
answers1911
views2 commands in the same python line
I wonder how I can fix this input('Acabei de encontrar a receita ') print('voce vai precisar dos seguindos ingredientes') num1 = int('6') print(num1) print('Kg de Farinha') num2 = int('3')…
-
0
votes0
answers413
viewsIndexerror: index 3 is out of Bounds for Axis 0 with size 2
D[i][j+1] = - u_med[i+1]/(delta_r[i]*delta_r[i+1]) Indexerror: index 3 is out of Bounds for Axis 0 with size 2 I’ve had another problem with that code and I asked here, but the problem now is this.…
-
0
votes1
answer166
viewsTreat functions that return multiple Python values
For example, I have a function mergeSort(alist)that has return return count, blist i.e., returns an integer that is the inversion counter and a list of values. When passing a list 5 4 3 1 2 5 and…
-
0
votes1
answer1280
viewsRecursive function in python to invert a number
I need to do a recursive function in python to return the number the reverse way, but be convert to string. I could only do it that way: import math def inverte(num): if(num < 10): return num…
-
0
votes1
answer358
viewsAnaconda Python Installation - Pycharm Projects
I use Windows 10 and recently realized that my files and projects developed through IDE Pycharm, as well as the installation of the Anaconda package, are located in a folder in the directory…
-
0
votes2
answers858
viewsFlask - sending form back to another function
Below is my default.py where I set the end-point; What I’m trying to do is get the information from FORM that’s on "/" send to the return_request() and append the result of Request in "/output" def…
-
0
votes0
answers76
viewsPython, downloading file on a given day and time
I’m looking to structure a Python program that downloads files (manga) from a given site once a week. I’m training, I took the course of web scraping, but I am lost on how to perform these requests.…
-
0
votes1
answer61
viewsHow to reuse class values?
I have three classes, the third one depends on the values of the other two (it depends on the E class Material and of A, Ix, Iu and Iz class Geometria. How can I do this? I know I need to correct…
-
0
votes1
answer177
viewsselect one of the words contained in the list
Type a word in a list and then search for the typed word lista = [] i = 0 palavra = '' while (palavra.lower() != 'sair'): i += 1 palavra = str(input('digite alguma palavra: ')) lista.append(palavra)…
-
0
votes2
answers65
viewsHow to do the inversion of what is received with comma addition?
Program that receives a name via keyboard and must print the last name, first name and other abbreviated names ex.: receives "Luis Costa Santos" and returns "Santos, Luis C." lista = [] nome = ''…
-
0
votes1
answer245
viewsMovements in the python Tkinter
I’m liking python, and I wanted to make an interface where there’s a ball that’s hitting the walls, only I wanted to know how I can make the ball hit the walls. from tkinter import * import time…
-
0
votes1
answer895
viewsUpload photo with model name in Django
I would like help for a task to save images with a custom name and a folder also with the current name, suppose the following Model: class ProdutoA(models.Model): nome_produto_a =…
-
0
votes2
answers76
viewsHow can the end of "for" be a user-defined variable?
In a for in C, we define "beginning, end and step increment". I know that in Python it is not so. I saw that it is called foreach. I wish the end of mine for is defined by the user. And that, at…
-
0
votes3
answers152
viewsSeparate the result that appears in os.getcwd() to be able to display only c:
Make a program that displays the current directory (which you are saving your programs to), the disk drive used, the system user name and the current folder. Consider the example below. Tip use the…
-
0
votes1
answer57
views -
0
votes1
answer770
viewsTurn two data lists into a graph with two parallel lines
Guys. I am since yesterday trying to do something that is very simple in Excel, but not in Python. I have two lists. Flap1 = [1,1,0,1,0,1] and Flap2 = [0,0,0,0,1,1,1] What I need to do is create a…
-
0
votes1
answer53
viewsDescriptor with meta class vs traditional
I’ve been watching the videos (example) by Luciano Ramalho on Descriptors with metaclass. I wanted to know the advantage of this model in relation to the more traditional implementation of…
-
0
votes3
answers1982
views"for" with step "float": Typeerror: 'float' Object cannot be Interpreted as an integer
I want to loop 0 to 100 with step 0.1: for x in range(0, 100, 0.1): a = cos(radians(x)) But I get this mistake: Typeerror: 'float' Object cannot be Interpreted as an integer How can I make a loop…
-
0
votes0
answers73
viewsRuntimewarning error
I am trying to run an array and the following error appears: Runtimewarning: invalid value encountered in double_scalars. What may cause it? def geomBarras(nx, ny, nz, fx, fy, fz): #determina…