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
-
-3
votes1
answer83
viewsI would like if someone can identify my error in this code in python:
def main (): d=[(1, 'Introdução a Sistemas de Informação'), (1, 'Programação I'), (1, 'Introdução ao Computador'), (1, 'Introdução ao Cálculo'), (1, 'Lógica'), (1, 'Comunicação e Expressão'), (2,…
pythonasked 5 years, 5 months ago user153299 -
-3
votes1
answer37
viewsmatch vectors using variables
Guys I just started in python, I wonder what’s wrong with that code. I wanted to pass the numbers of valores for valoresI always skipping a position, so the x += 2. But he keeps making mistakes. If…
pythonasked 4 years, 1 month ago lucas gabriel 9 -
-3
votes3
answers1399
viewsPython Range - Numbers in descending order
I need to generate a list with even numbers of N until 0. For example, if I inform 8, I have to print 14, 12, 10, 8, 6, 4, 2, 0. My program, below, is returning 9 numbers, going up to the 16. Where…
-
-3
votes4
answers201
viewsHow to reduce Python code 3?
a simple algorithm to read an X integer and print the next 6 odd ones (including the odd X) X = int(input()) if X % 2 == 1: print(X) X+=2 for i in range(5): if X % 2 == 1: print(X) X+=2 else: X+=1…
-
-3
votes2
answers56
viewsStop the loop or not
Good morning, I’m having difficulty putting a condition in this loop: if tighten 1 loop for loop if tighten 2 out of loop resp=1 while resp==1: cliente_nome.append((input("Digite o nome do Cliente:…
-
-3
votes1
answer147
viewsPython: How to get a dictionary key based on the value?
I have a dictionary in table format={"t":148} I can return 148 by doing table["t"], right? How can I make to return "t" based on the 148? When I try to print table[148] ends up returning "None",…
-
-3
votes3
answers174
viewsCondition "If" does not enter the structure
I’m having a problem with my code,I get an xlsx file, and I do the whole procedure correctly. but the file comes with some commas that need to be removed, and when I do the if to check if it has the…
-
-3
votes1
answer52
viewsHow do I check if a STRING has more than 3 characters?
I need to check if a string has more than 3 characters, how do I do this? I’ve tried it like this: nome = input('Digite um nome: ') a = [i for i in enumerate(nome)] print([i for i, y in a]) if a…
-
-3
votes3
answers87
viewsWorking logic error with list
I’d like to know how I make the result equal to: esta é a lista[{'h': 'h'}, {'h': 'j'}, {'h': 'z'}] a, b= ['h', 'j', 'z'], list() c= dict() for i in a: print(i) c['h']= i print(c) b.append(c)…
pythonasked 3 years, 10 months ago Jss Albert 1 -
-3
votes1
answer82
viewsHow to skip the line in python input?
Hello I’m making a code here to send emails, and I wanted that at the time of the inputs of the message when I hit the Enter it jumps the line and does not stop the input, that it only stops when…
-
-3
votes1
answer34
viewsProblem with Python Dictionaries
def main(): insereDic() def insereDic(): frase = input('>>>') for i in frase: if i in dic: dic[i] =+ 1 else: dic[i] = 1 print(dic) dic = {} main() Statement of the Year…
pythonasked 5 years, 2 months ago Bryan Ribeiro Melo 5 -
-3
votes3
answers64
viewsHow to receive a list of each date between two dates in python
At the point I’m at now, I need to get a function that returns me a list of all the dates between two dates. I don’t know exactly how to do this operation, if I can use some specific library as…
-
-3
votes1
answer42
viewshow to turn the list into a single string
I would like my code to result instead of a list a single string Ex: n = 5 the code returns me [1, 2, 3, 4, 5] I would like it to return me '12345' transforming all elements into a single string.…
-
-3
votes2
answers228
viewsCreate shortcut with python
I’d like to know how to create a shortcut for my own script . py using Python. I mean, my code creates a shortcut of its own.…
-
-3
votes2
answers64
viewsBug when adding elements to the list and transforming it into a string
I’m trying to headache in the course of a mini-project to develop a hangman game, in the function that would return the string containing the hidden word, showing only the guessed letters. I’ve…
-
-3
votes2
answers73
viewshow to print words with 7 or more than 7 letters in python
I have to make a code that prints names with more than 7 letters I’m using the pycharm my code is as follows:: nome = input("Digite os nomes separados por vírgula: ") nomes = nome.split(',') def…
pythonasked 3 years, 8 months ago user225150 9 -
-3
votes1
answer26
viewsWhat is the mainloop functionality in the Tkinter frame?
I was trying to make a frame appear on the screen on Tkinter, and after a lot, I tried to check the documentation and saw the name "mainloop", when testing it appeared on the screen, which I did not…
-
-3
votes2
answers160
viewsHelp with PYTHON lists
I’m doing a college paper, but I’m having a hard time finishing a code. Image of the activity: I’m trying to make a list. Yeah, I think that would be an effective way to solve this exercise.…
-
-3
votes1
answer169
viewsHow to display in a Label the result of 2 other Labels in Python
I am creating the following budget program with Python and Tkinter. # Copyright (c) Todos os Direitos Reservados a Daniel Heringer import locale locale.setlocale(locale.LC_MONETARY, locale= 'PT-BR')…
-
-3
votes0
answers38
viewsUrgent question Python
Knowing the number of the specific line in a TXT file, how do I convert all the text of that line into a String type variable? For example: I have line 5 written : "Hello world"; and I want to turn…
pythonasked 3 years, 7 months ago Pierre Bento Bonagurio Moraes 1 -
-3
votes1
answer36
viewsHow to store values at each interaction during the repetition of a structure - Python
lista= ["2,55","3,4","3,83","5,1","6,8"] for i in range(len(lista)): lista[i] = lista[i] #PREEENCHER VALOR navegador.find_element_by_xpath('...').send_keys(lista[i]) time.sleep(3) #obter valor #…
-
-3
votes2
answers61
viewsIs there any way similar to the python . format method for VBA in Excel?
In python using the . format for this: users = ['profile1', 'profile2'] print("www.instagram.com/f{users[0]}/") Would soon come out: www.instagram.com/profile1/ Is there any similar method in vba?…
-
-3
votes2
answers122
viewsI have a job in Python 3 and do not know how to proceed
I need to make an algorithm that asks the user for numbers and stores them in a 20 position vector. Create a function that receives the filled vector and replace all occurrences of negative values…
-
-3
votes1
answer107
viewsI’m learning python and I’m not finding out why the script doesn’t work, this is a tutorial on youtube someone can help me
from selenium import webdriver from selenium.webdriver.common.keys import Keys import time import random class InstagramBot: def __init__(self, username, password): …
pythonasked 3 years, 7 months ago Edésio José 1 -
-3
votes1
answer57
viewsError while using pandas in pycharm to read excel file
I am trying to use pandas in pycharm to read an excel file but it returns me many errors as appears in the image, I have tried to change the file path,use r before the way, at last nothing is right…
-
-3
votes1
answer66
viewsPRINT command is set to INVALID SYNTAX in Python
I’m doing a simple exercise in python and I don’t understand the reason for my mistake. num1 = (int(input("Digite o primeiro número")) print("Digite a operação desejada, sendo:") print("* -->…
-
-3
votes1
answer90
viewsProgram that shows the location in a queue
This program will show the location of a person in the queue when typed the name, however, I’m not getting. Error: File "C:/Users/Cleit/Pycharmprojects/xxx/xxx.py", line 79, in import Queue…
pythonasked 5 years ago Cleiton Do Carmo 11 -
-3
votes1
answer33
viewsSeparate Dataframe Column in List
I have a Dataframe with three columns: Categoria Label Porcentagem Cat1 Label1 40 Cat1 Label2 10 Cat1 Label3 25 Cat1 Label4 25 Cat2 Label1 50 Cat2 Label2 50 Cat3 Label3 100 I need to turn the…
-
-3
votes1
answer33
viewsHow to concatenate two types of different values but of the same input into a list in python?
I have the following code that reads a person’s name and age: pessoas = [] p = [str(input('Digite o nome e a idade da pessoa no formato: "Nome 23": '))] pessoas.append(p) print(pessoas) Supposing I…
-
-3
votes1
answer42
viewsHow to use IDLE within a virtual environment?
When we install Python it automatically installs an IDLE together, but when creating a Virtual Environment it does not install. How do I gain access to IDLE within a virtual environment?
-
-3
votes1
answer38
viewsPYTHON - How to create a list containing each element from a previous list within another list
I think the easiest way to describe the problem is to show the goal, otherwise it gets confused. I need to turn something like this: [['3 -1 2 0 2 0 -1 -1', '4 2 4 5 1 0 0 1 1'], ['6 -8 -8 15 15 0',…
-
-3
votes1
answer48
viewsTurn a column into several other columns into a pandas data frame
Good morning! I need a help... I’ve tried several commands but I think I’m going a long way. I have this dataframe: And I need to turn this:…
-
-3
votes1
answer39
viewsDoubt in Python Ties
Guys have been breaking their heads here for a while, and in a small detail, how do I display below average values? , I’ve already put the go through the list but not the printa. And also the…
pythonasked 3 years, 5 months ago Ana Carolina 1 -
-3
votes0
answers23
viewsHow to hide a print after the Sleep function in pycharm
guy from time import Sleep print('Loading ...') Sleep(3) Eaí ? after Sleep, how to hide the print 'Loading'? please, answer as simple as possible, I am beginner rs ps: I am trying to do this in…
pythonasked 3 years, 4 months ago Pedro Phillipe 1 -
-3
votes1
answer45
viewsedit python function
I’m writing an algorithm that calculates the average of continuous variables and I pass to it a function with the specific function: def media_variavel_continua(func, ini, fim): return quad(func,…
-
-3
votes1
answer34
viewsReceiving data on multiple lines
I need to create a code that will calculate the average, variance and standard deviation of the data entered by the user. I thought of throwing this data into a list and from then on working them…
pythonasked 3 years, 4 months ago Isabela Pereira dos Santos 1 -
-3
votes1
answer106
viewshow do I make an Nxn matrix, where N is a variable (acquired in input), in python. Because the example below cannot change the values in the indices?
E1 = input(). split() E2 = input(). split() Matri, numj = E1 name, idj = E2 matrix = [[0,0,0],[0,0,0],[0,0,0]] # I cannot make the matrix that is the user’s choice, that is a variable.. for l in…
-
-3
votes1
answer40
viewsHow do I put a close button on my python file?
I’m starting in python and I’m writing a code, but when all the actions end the program closes, how do I put a command where for example click ESC and it closes? I want that when the person does not…
-
-3
votes2
answers56
viewsCount how many times a certain value appears in a list
I need to write a code that creates a list of numbers that are entered by the user (the amount of numbers is defined by the user) and print which value of that list is the largest and how often it…
-
-3
votes1
answer85
viewsError <Generator Object <genexpr> when reading Python matrix
I want to read matrix by placing the commas to separate the numbers, but when I ask to show the matrix, it gives this error: <generator object <genexpr> That never happened to me, I have no…
pythonasked 3 years, 3 months ago Garota de Programa 7 -
-3
votes1
answer201
viewsChatbot not understanding registered phrases
I’m developing a Chatbot called "Joker" for use in a Telegram group. The Bot must respond only if its name (Joker) is quoted in a sentence, otherwise it must remain "silent" without interfering with…
-
-3
votes1
answer1405
viewsValueerror: could not Convert string to float:
Exception in Tkinter callback Traceback (Most recent call last): File "/usr/lib/python3.7/Tkinter/init.py", line 1705, in call Return self.func(*args) File "/home/Oswaldo/Calc.py", line 29, in…
pythonasked 4 years, 10 months ago Code Main Project 1 -
-3
votes0
answers36
viewsMachine Learning Usage Tip to Rank Small Phrases
I have a script that gives me 3 short sentences (about 20 words) in English to sort. I’ve never done it before, but I thought a machine learning algorithm could learn how to classify these 3…
python algorithm machine-learning artificial-intelligence machine-learningasked 3 years, 3 months ago thecuriousironman 1 -
-3
votes0
answers26
viewsCopy text from Wikipedia in Python
Hello, I was wondering how I can copy the text of a page in Wikipédia, it can be only the first paragraph on the subject Here’s what I’ve done: from selenium.webdriver.common.keys import Keys…
-
-3
votes0
answers15
viewsTake a part of the string from a specific character
How I only take what’s between the comma: s="oi eu sou ,feliz,: )" Type an example function: estado= s.getac (",")
-
-3
votes1
answer22
viewsInput in Selenium with Python
I started studying the tool selenium there are exactly 2 hours and I was wondering if it is possible to do the following: Run a program and it ask me the site I want to access, paste the link and…
-
-3
votes0
answers8
viewsKnow if pyttsx3.engine stopped it’s talk Function completely
I am using the API pyttsx3 on Python, but I am having difficulties regarding the "isBusy()" Function in it’s engine, which doesn’t Seem to Return if the engine completely stopped Talking, which I…
-
-3
votes0
answers15
viewsbest way to store user profile images
What is the best way to store a user’s profile image? using python, flask, mysql. I am developing a user registration system and want to store profile photos, I saw that storing the image itself in…
-
-3
votes1
answer124
viewsWhat’s wrong with my python code?
I’m making an app to film the desktop with system audio and microphone. Initially it seemed simple but I found a problem on the way:I’m not able to record the sound of the system.Initially I thought…
-
-3
votes0
answers26
viewsPython optimization
Is there any way to optimize the code below? I feel like I used many "Fors". texto = '' num = 10 for c in range(1, num): linha = '' for v in range(1, num - c): linha += ' ' linha += '/' for g in…