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
votes2
answers3618
viewsGrab specific column csv with python
I have a method that opens a CSV file but would like to go straight into a specific column, I tried to do it this way list2 = [row.split()[3] for row in f], but returns a piece of the file and not…
-
0
votes2
answers926
viewslimit the number of digits Entry - Tkinter
Hello. How do I limit the number of digits I can put into one Entry module Tkinter? from tkinter import * root = Tk() entrada = Entry(root) #Quero limitar para que nesse entry, possa colocar apenas…
-
0
votes1
answer205
viewsError accessing localhost:8000/profile
page profiles.html <!DOCTYPE html> <html lang="pt-br"> <head> <meta charset="utf-8"> <title>ConnectedIn</title> </head> <body> <h1>Detalhe…
-
0
votes1
answer98
viewsRemoval of Duplicate Elements : divide and Conquer
I’m having trouble getting an algorithm that removes duplicate elements in an array (can only be integers), which uses the method Divide And Conquer. I am in need for a college job, and…
-
0
votes1
answer51
viewsIs it possible to write all the paragraphs that the user only put after the loop in sequence? and in a justified way?
Is it possible to write all paragraphs that the user has put only after the loop in sequence? and in a justified way? import textwrap numero_paragrafos = int(input('Quantos parágrafos tem o…
-
0
votes1
answer121
viewsPage search program for a Python website
I want to write a code in Python that accesses a site by placing a list of words at the end of the URL to find the pages of the site, with a timer. I did but it does not return me the name of the…
-
0
votes1
answer53
viewsHow to proceed with batch execution for python methods
I have the following code below: def exemplo01(): return 'exemplo01' def exemplo02(): return 'exemplo02' def exemplo03(): return 'exemplo03' def run(): #list of <class 'function'> fx = []…
-
0
votes1
answer117
viewsPython Guess Game
I was doing a job, and I ran into some problems. This code has a limitation: Whenever the player selects some number that has been selected before the code does not invalidate and is considered as…
-
0
votes1
answer52
viewsPut Which Letters Repeat Most and In Order
How I Do to Do a Function that Traverses a Text Text = "TEST" and put the function in order for me The most repeated letters with Dicionario Ex: DICTIONARY = {T:2 , E:2 , S:1} Just as there is in…
pythonasked 6 years, 1 month ago Lucas Oliveira 1 -
0
votes1
answer25
viewsHow to add a sheet to a pre-existing xlsx file with pandas?
Follow my attempts. And still unsuccessful. import pandas as pd def data_frame(): return pd.DataFrame([{'link': 'http://brito.blog.incolume.com.br', 'title':'Blog'}{'link':'http://google.com',…
-
0
votes1
answer188
viewsSearch error cep invalido
I am trying to make an application to query a list of cep’s that I have, but when ex: cep=40717000 does not exist is displayed an error and I can’t proceed to the next record of the table, can…
-
0
votes4
answers208
viewsIdentify missing value in numerical sequence
There is a set of cards numbered from 1 to N. Among this set a card was lost, determine the number of the lost card based on the remaining cards. Given an N number, followed by N-1 integer values…
-
0
votes1
answer748
viewsConvert an entire txt file. Python
Good morning. I am a beginner in Python language, I use Windows 8.1, id Pycharm, version 3.6.4. At first opening the file has not been the problem, before converting it to integer number. Only then…
pythonasked 6 years, 6 months ago Peçanha De Oliveira Eduardo 1 -
0
votes2
answers1460
viewsCalculate the sum of a range of numbers entered by the user
Read 15 numbers typed by the user and calculate the average values between x and y positions (inclusive). I started trying to do... numeros = [] for i in range (1, 16):…
pythonasked 6 years, 1 month ago Daniel Malafaia 11 -
0
votes1
answer159
viewsPython - problem with PIP (or modules)
I am developing a program equal to word direct evil, however, which also allows naming each file in the folder. I installed on my PC (Windows 7) Python 3.7 and, to develop the program I needed to…
-
0
votes1
answer596
viewsHow do I turn my results into txt, excel or word file?
I have a code in Python that does the following: Extracts several data from different tables and performs a linear regression between them. So far so good but how do I make my results come out clean…
-
0
votes2
answers286
viewsPython: How to identify the root of the operating system?
As I identify the root of the operating system (windows: "C: ", No linux: "/"), exclusively through python commands that apply to both systems?
-
0
votes3
answers178
viewsis not accumulating values in the lists
list1=list() Lista2=list() def lê_e_verifies(): """reads an integer and checks whether this correct returns the integer read""" while True: try: inteiros= int(input("entre com numeros1 ")) inteiros=…
-
0
votes1
answer311
viewsHow to reverse the association of one file to open with another in Pycharm
I picked up a song I copied and glued to the pycharm. The song was not recognized, appearing the option Associate with file type, when I clicked associated the program to youtrack query , as I do to…
-
0
votes1
answer187
viewsSimulation of Monte Carlo
Good morning, I came across the following terms: Simulation of Monte Carlo first order and second order. I’ve been working with MMC for a while but I’m not familiar with these terms and I couldn’t…
-
0
votes1
answer724
viewsSite with hidden HTML
I need to extract the sales data of semi-new cars on some websites. One of the sites is the Locamerica company. However, on her website does not appear in the HTML page the content I need to…
-
0
votes0
answers75
viewsHow do I convert the image data to float? Or is there something wrong with the code?
I’m testing a code and I had problems: I can’t see the image. The message that appears is: Typeerror: Image data cannot be converted to float (picture data cannot be converted to float) CODE: from…
-
0
votes1
answer63
viewslist index out of range, genetic algorithm
I’m having trouble with the line you’re on parcial += pacum [i-1] I am with the error "list index out of range", about the variables and lists: list population and fitness depend on the…
pythonasked 6 years, 6 months ago Patrick Amaral 88 -
0
votes1
answer235
viewsPython: Slow code execution and other problems
Dear colleagues, Can someone enlighten me on what might be going on? In summary, it is a code to read cells from a spreadsheet, sort and transport to a new spreadsheet. The problem: The code does…
pythonasked 6 years, 6 months ago Wilson Junior 182 -
0
votes1
answer231
viewsHow to create a tridiagonal matrix in Python?
Hello, I would like to know how to write a tridiagonal matrix Nxn. I have three vectors that will be updated in a loop. I’m working with something semlhnante to this: Note: I would just like to know…
-
0
votes0
answers63
viewsRaise Xlrderror - Indicating Sheet_name Python
Good morning. I’m starting with Python and I have a problem. I have N files in Excel and need to read the sheet_name of each indicating their name, the code I have so far is this: os.chdir("work…
-
0
votes3
answers3591
viewsHow to use "while not in" in Python?
I tried to loop with while to check if a condition was met. If the user enters 0, 1 or 2 the program should stop asking the user which number he will choose. If the user chooses a number other than…
-
0
votes1
answer133
viewsadd number and delete n in python
I have the txt file: NOME,n1,n2 JOAO,8,5 MARIA,5,6 PEDRO,0,9 I want to add up the numbers, I did it this way: arq=open('pergunta.txt','r') conteudo=arq.readlines() arq.close() for i in conteudo:…
pythonasked 6 years, 1 month ago Matheus Andrade 205 -
0
votes1
answer42
viewsHow to store various user read values?
aluno = int(input('Qual o numero de alunos ? ')) for i in range(aluno): nota = float(input('Insira a nota de cada um dos alunos: ')) I need to know how I store students' grades to add and divide by…
-
0
votes1
answer76
viewsHow to get back the amount of an existing word within a.txt file?
I’m trying to get as a return the amount of low-level words (bad words) in one text, using as a basis another file . txt containing the words (bad words). The code I made only returns 1 (one)…
-
0
votes2
answers324
viewsSingleton pattern in Python
I was watching this article on how to create Singleton classes in Python (among many others), I found unnecessary so much programming technique for a really simple thing. Of course I could be wrong.…
-
0
votes1
answer578
viewssearch for data in a python json
I have the following code with open('states.json') as f: data = json.load(f) for state in data["jquery"]: if(argumentos[2] == state['version']): print(state['name'], state['version'] + "existe")…
-
0
votes2
answers326
viewsI need to make a Python entry by storing it as a list, all in one line
I am doubtful in a college exercise, I need to store 3 data which are: Vehicle number, mileage and consumption in each variable of type list, but due to be different types, with the first 2 being…
-
0
votes1
answer487
viewsNo module named - Python
Hello, I did the installation of mailchimp3 this way: pip install mailchimp3 And also from Makilchimp: pip install mailchimp They did not present any error. When I’m going to perform the tapeworm in…
-
0
votes1
answer1303
viewsRemoving elements from a list
I’m having trouble with my code. print('inserindo e removendo itens da lista\n') bom_dia = [] bom_dia.insert(0, 'python') bom_dia.insert(1, 'a') bom_dia.insert(2, 'b') print(bom_dia) print() del…
-
0
votes1
answer54
viewsCan I set Else to do two things?
I want to make a function in case the name entered is invalid, the program shows that the name is invalid and in addition, close the program or return to the starting point, this is possible in…
-
0
votes1
answer356
viewsDjango login view only works with users created in createsuperuser
I’ve been racking my brain with this problem for a couple of days. I’m doing a project for college and created a custom user, I can add users normally in my registration template, they are committed…
-
0
votes1
answer41
viewsReorder elements of a query on the screen
I have an application in Django and need to reorder the screen elements when the user decides to sort by date, popularity, etc.. I would not like to submit a new query each time the user selects a…
-
0
votes2
answers91
viewsUnicode troubleshooting when trying to save a picture with latex text in Matplotlib
Talk personal. I have a problem using the Matplotlib library. Before the last Windows update I used the library without any problem. I basically use it to create function charts and save them on.…
-
0
votes1
answer41
viewshow to take out data and add to an existing Python function
I’m creating a little game of dice but when I want to put a contain of points I’m not getting... def get_dados(): dado1 = int(input("Digite o número para o primeiro dado: ")) dado2 =…
-
0
votes1
answer407
viewsSpecific chunk break in JSON file with python
Is it possible to break a line from a specific section of Json, transform it into an array, and then streamline it? Why do I ask this.. I am developing a file mining bot and came across a situation…
-
0
votes1
answer1501
viewsRun python code via batch in the anaconda cmd
I have a batch created to run a python file, but it is opening the windows cmd and since python is installed in anaconda, does not work, it would run directly from the anaconda cmd as administrator?…
-
0
votes1
answer69
viewsoutput function giving error syntax
lista1 = [1,2,3,1,1] lista2 = [2,2,3,1,3] res = list(input("Digite seus inteiros")) def exibiçao(lista1,lista2,res): print("{} {} {} {}…
-
0
votes1
answer410
viewsSort TXT lines in numerical order
I need to invert all the columns of my txt file, using python. txt file (example): Regra n10 - exemplo Regra n9 - exemplo Regra n8 - exemplo Regra n7 - exemplo Regra n6 - exemplo Regra n5 - exemplo…
-
0
votes1
answer115
viewsError in Phyton script
I downloaded a script (I don’t know if this is how to say it, I’m starting programming today) of a game made in python but I can’t run it because there is an error File "C: Users mah14 Desktop…
pythonasked 6 years, 6 months ago Matheus Almeida 1 -
0
votes2
answers4222
viewsHow to find and show the position of an item in the list, not setting the string value for the search?
How to find and show the position of an item in the list, not setting the string value for the search? Ex: nome_pessoa = str(input('Informe o seu nome completo: ')) lista_nomes = nome_pessoa.split()…
-
0
votes1
answer333
viewsMessage in "print" is not printed on the screen, how to fix?
The message of print does not appear on the screen, does it have to do with the variable? cp = str input("seu nome") if(cp)=='jefferson': print('JFP')
-
0
votes1
answer76
viewsIs there any way to reference an Enum inside itself in Python?
I would like to use a constant I created in an Enum as an attribute of another, for example: from enum import Enum class Jokenpo(Enum): PEDRA = ('Rock', [Jokenpo.PAPEL], [Jokenpo.TESOURA]) PAPEL =…
-
0
votes1
answer69
viewsCode Mandelbrot set
I am studying a specific code of the set of Mandelbrot (equation with complex numbers) with a focus on object-oriented programming. However, there is a specific part I did not understand of the…
-
0
votes1
answer123
viewsDoubt Points Recognition with Opencv and Dlib
Hi, I’m looking to do facial recognition with Dlib and Open via Webcam but I’m having a mistake with Numpy that I can’t solve, if someone can give me a hint would be of great help. My Code. import…