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
votes2
answers684
viewsHow to detect line breaking in Python input?
I need to read test cases of the following format: 3 1 2 3 4 52 2 1 87 10 51 32 1 36 21 34 32 12 34 45 200 (... 200 numeros separados por espaço) and so on, where the first number indicates the…
-
2
votes2
answers2510
viewsDjango - select options
I’m trying to put the names of the coordinators in the options of a select looking for the database, I already searched and it seems that there is another way to use select on Django, but it was not…
-
2
votes3
answers502
viewsPython - Cycle for as an alternative to the while cycle
General considerations: I am currently programming in python; I have a relatively simple level code; The code contains an instruction cycle of the type while loop; I would like to know if there is a…
-
2
votes2
answers112
viewsImplement a program that has a name and only has the last name and first name
I made him this way: nome=input('Digite seu nome completo:').title() lista=nome.split() print(lista) print(lista[-1],',',lista[0]) But when it’s time to print, it looks like this: Fulano , Ciclano…
pythonasked 6 years, 1 month ago Matheus Andrade 205 -
2
votes3
answers155
viewsSimple question about the title() command
if I put for example the name: Roberto justo da silva using the title he gets like this: Roberto Justo Da Silva How do I make the command title do not change the word 'da' to look like this: Roberto…
-
2
votes3
answers9053
viewsMultiplying terms from the list
I want to print the multiplication of the terms and I would like to know if there is a function capable of doing this for me in the Python language: lista = [] con = 0 while(con<5): n =…
pythonasked 6 years, 1 month ago Programador em formação 71 -
2
votes1
answer428
viewsPython pandas very slow
Can anyone help me? I am reading a file, make some changes and then saved in another folder. but that takes 2 hours, the file has 15 million lines, would have some different and more effective…
-
2
votes2
answers102
viewsHow to display the attributes of an Exception in Python?
I’m doing some exercises with exceptions created by me in Python but I don’t really understand this part of attributes in exceptions. I wanted when the code fell on Exception, it would show a…
-
2
votes2
answers445
viewsRun terminal from Python script
I am doing a work of distributed systems, in which I am using PYRO, in it I am using objeto.adapter.rebindURI() to use the same object when the server that was (dropped) is "restarted"... I’m hoping…
-
2
votes1
answer129
viewsReturn in a Dataframe - Python
Good afternoon. I have a question about Python. I have an if where he has the conditional and Else, the Else he processes more than one file and I need to save all the information he reads inside a…
-
2
votes1
answer250
viewsError deploy Heroku app Django
After deploying to Heroku, I opened the link to my application (https://silima.herokuapp.com/), and it presented the following error: ProgrammingError at / relation "Produto" does not exist LINE 1:…
-
2
votes2
answers5334
viewsHow to check the versions of the modules installed in Python?
I installed two modules in Python via anaconda (Conda install): zipfile36; Mysqldb. Using the anaconda prompt I can get the version of both and all my other modules using the command: conda list But…
-
2
votes1
answer296
viewsHexagonal matrix in Python
I would like to know how to return the numbers of a vector (matrix) within a specific R (radius) using Python. Follow on this image: Following the vector used: mapa = [ [0.0, 0.1, 0.2, 0.3, 0.4,…
-
2
votes0
answers54
viewsError trying to disconnect using social-auth-app-Django
Good afternoon, everyone, I am building an application in Django, where it is necessary for the user to authenticate through his Microsoft account, for this, I am using the library…
-
2
votes1
answer806
viewsPandas: Dataframe information comparison
I have 2 Dataframes imported from CSV CSV1 4616; CCIVIL_03/decreto/2003/D4616.htm 4617; CCIVIL_03/decreto/2003/D4617.htm 4618; CCIVIL_03/decreto/2003/D4618.htm 4619; CCIVIL_03/decreto/2003/D4619.htm…
-
2
votes2
answers4377
viewsRegex for monetary values
I would like to know how to do a regex to capture a monetary value with semicolons. Ex: 7.300.250,00
-
2
votes1
answer580
viewsbreak list by python size
Today I came across the need to break a list of over 100 values in a list of lists with a maximum of 100 values. I researched a lot, and in the end I put together the function: remove_list=[[]] n=0…
-
2
votes1
answer559
viewsRead file information. txt using Python
Good night! I have a. txt file that stores a data structure as follows: índice: p1[x1, y1], p2[x2, y2], p3[x3, y3], p4[x4,y4] An example of lines in my file is: 1: p1 = [62.61, 79.47], p2 = [64.17,…
pythonasked 6 years ago Raphael Müller 21 -
2
votes1
answer176
viewsstring treatment on pandas
Good evening Gentlemen, I have the following Dataframe, imported from an xlsx. NUM_LEGISLACAO DSC_URL COD_SITUACAO ... DSC_TIPO num ano 264 89.272/1984 NaN 2.0 ... NORMATIVO 89.272 1984 265…
-
2
votes1
answer159
viewsHow to delimit plotting area in python?
The figure is cutting the captions, how do I fix it? # Libraries import matplotlib.pyplot as plt # Make data group_names=['0,89% - Tração Animal e Propulsão Humana', '45,08% - Passageiro e Misto',…
-
2
votes2
answers196
viewsMultiplication and division result with two boxes after the comma
Hello everybody all right? I’m doing an activity for my python course, it’s a script that basically calculates the area of a wall in meters and tells how many liters of paint will be used. The…
-
2
votes1
answer642
viewsReturn the largest number in Python with recursion
My teacher started talking about recursion, and passed a few exercises, only I stalled on a. As stated in the following statement, I must create a function that returns the highest value contained…
-
2
votes2
answers1014
viewsFind the maximum and minimum number in a list in a string
I have the following file: a = '1 0 10 2 3' I want to print the highest value and the lowest, so I used the max() and min() but it only counts the unit. I did it this way: a='joao 1 0 10 2 3'…
-
2
votes2
answers399
viewsIs there a method in Python similar to x.find(string), but which returns all occurrences?
For example, I have a string with several occurrences of a: a = 'abcdefhanmakaoa' If I use the method find, I can only find the index of the first occurrence. There is some native method/function…
-
2
votes1
answer505
viewsTransformed problem of Fourier
I’m having a problem using the fft function of numpy. When rotating it, the answer is giving different from the Fourier transform that I implemented manually and by the tests I did the manual seems…
-
2
votes2
answers1413
viewsRemove blank lines in a csv
I am trying to remove empty lines from a csv document: Document: phrase, .,pt .,en .,en .,it .,es .,pt .,pt .,es .,pt .,pt "it’s not Expensive",en "casi 50 euros la alfombra es cara", " the price…
-
2
votes1
answer1546
viewsRemove score from a Python file
I have this code: dataClean = ''.join(data).lower() dataClean = re.sub(r'["-,.:@#?!&$]', ' ', dataClean) print(dataClean) Where data is an array of a text file. My goal is to remove punctuation,…
-
2
votes1
answer48
viewsAre there problems using special characters in Python codes?
Thinking of leaving the codes more sleek and sleek would it be possible to use special characters in the codes? It would bring some problem?
python character-encoding encoding-style source-codeasked 5 years, 11 months ago Raul Nascimento 103 -
2
votes0
answers106
viewsElements/Images Problems in Selenium Django
I’m having some element problem not load correctly on the page of ChromeDriver using Selenium in my Django app. I shook Django’s test tool because in my scenario, I need the entire base loaded. And…
-
2
votes2
answers860
viewsLambda in Python - Doubt
In study on python 3, what would be the function of lambda in Python, what it serves and when it is used?
-
2
votes1
answer1458
viewsRecursive function that returns the sum of the digits of a number
I need to create a recursive function that takes a number n integer and returns the sum of the digits of this number. I made the following code but it’s giving None: def somadig(n, s = 0): if n >…
-
2
votes2
answers206
viewsReplace words between two files
I’m trying to do some overwriting between two files: if a word from file 1 is in the second column of file 2, replace that word from file 1 with the word from the first column of file 2 File 1:…
-
2
votes1
answer192
viewsProblems with __eq__, __lt__, etc. and the method removes from the list object
I’m having the following problem, I have a letter class and use the magic methods eq, ne, le, it’s, ge, gt to be able to compare the value of two cards and also to be able to use the Sort function,…
-
2
votes1
answer180
viewsIndentation error
I’m trying to create a TextInput in the Kivy and define its dimensions, only whenever it puts its dimensions of error: invalid indentation,must be a Multiple of 4 Spaces. I still don’t understand…
-
2
votes3
answers1463
viewsFor with python time
Good morning Personal! Can someone help me if it is possible to create a for in Python using timetables? Example: Set a start time for for and the other ending and the every 1 hour that for run…
pythonasked 5 years, 11 months ago Andre Batista 41 -
2
votes2
answers551
viewsstring manipulation python
I am having a problem regarding python b (Backspace), instead of deleting the previous character, it generates a "•" as the image below: Follow the line of the code that generates this return: #-*-…
-
2
votes1
answer899
viewsConvert Days & Time (Hours x Minutes x Seconds) to Time only
I have a Dataframe in which I am making the difference between two different dates to get the difference in Hours and Minutes, for example: data_inicial = '2018-07-03 16:03:00' data_final =…
-
2
votes0
answers79
viewsDefault accents when passing data from a txt to a Python list
I have a python script that takes words from a ". txt" file through the open method and puts them in a list. However, if the word in the text file has some accent, when passed to the list in python…
-
2
votes3
answers3749
viewsProblems with input results after using an "int()"
Code example: idade = input("Qual a sua idade? ") int(idade) if idade >= 45: print("Tá velho cara, já era!") else: print("A vida está só começando rapaz!") Error found: Qual a sua idade? 45…
-
2
votes2
answers254
viewsIntensive python course by Eric Matthes ex8.10
I’m having difficulty doing an exercise of the book 'Eric Matthes' intensive python course the exercises is as follows: 8.10 - Great Magicians: Eat with a copy of your 8.9 exercise program. Write a…
-
2
votes1
answer4177
viewsHow to create a list and put other lists inside?
def annexsentence(): nome_tarefa=input("Nome da Tarefa :") data_atual = datetime.datetime.now().strftime("%d-%m-%y") data_final=input("Data Final :") estado="Aberta"…
-
2
votes2
answers13516
viewsCould not convert string to float. Why?
I tried to convert some values to float self.total_PreçoCusto = float( self.PreçoCusto) * float(self.estoque) self.total_Preço_Venda = float( self.Preço_Venda) * float(self.estoque) self.lucro =…
pythonasked 5 years, 10 months ago Lucas Costa 29 -
2
votes1
answer397
viewsSize of tuple lists in a df
I have the following df n_words Words . 220 [('trabalho', 17), ('monitor', 17), ('via', 16... 3114 [('atend', 863), ('ortopedico', 863), ('proced... 5 [('anomalos', 2), ('feixes', 1),…
-
2
votes3
answers5398
viewsCount number of times letters repeat in a text
Can anyone give me an idea of how to write this algorithm in Python in fewer lines ? (The algorithm counts the amount of a given alphabet letter in a string). #INSERINDO TEXTO string=input("Digite a…
pythonasked 6 years, 4 months ago user114629 -
2
votes1
answer298
viewsDetermine sequence of numbers with Bubble Sort from a python txt file?
I have a txt input file with data type the below: 7 6 8 4 8 5 0 1 2 1 0 3 2 3 0 This file is about information for 3 students of a school. The first line is the age of these 3 students (the first…
-
2
votes5
answers4459
viewsAccess dictionary within a Python list
I have the following list whose elements are dictionaries: [{'nome': 'ana', 'cpf': '1000', 'endereco': 'rua xxxx'}, {'nome': 'carlos', 'cpf': '7770', 'endereco': 'Rua aaaa'}] I want to do the search…
-
2
votes2
answers3679
viewsHow can I add a character to each element of a Python string?
We have the following list: list=["oi","meu","nome","é","Gustavo"] I want to add a character at the beginning of each element of the list (added the name opa in each element manually same :p):…
-
2
votes3
answers1165
viewsPass a variable from one function to another
Hi guys, okay? Next, how could I send the variablemts_quadrados of def prog( ) to be calculated in def prog_main( )? def prog(): print("Informe o valor: ") cli() mts_quadrados = int(input(":"))…
-
2
votes1
answer960
viewsHow to run a function after a certain time in Pygame?
I’m making a game with Python, in which character jumps obstacles and falls after a few seconds. In javascript I used the setTimeOut function for this. In Python I tried to do the same thing with…
-
2
votes1
answer2244
viewsConvert Python to exe
I have an app made in python that pulls several Imports, and my client does not want to install Python in his environment (because it is an Oracle server), the output I found was to create one . exe…