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
votes0
answers57
viewsWhat is the shortcut to the "C" key in Pygame?
You can use this key with the Event.key method? What is the key call? I am developing a simple and accurate Synth of sounds of as many input keys as possible. import pygame if event.key == K_v:…
-
-1
votes1
answer43
viewsHow to give the same answer to different possible user entries
I made this code to try to get different types of user response options, for example if I answer "good morning" or "GOOD DAY" in both I can get the same output: print('Olá! Sou Maria, fale comigo!')…
-
-1
votes1
answer61
viewsFunction for Python Sum and Average
I am trying to develop these functions, when I type the numbers 1, 2, 3, 4 and 5, they return me the results 1 and 0,2. Can help me know what I’m doing wrong? def soma(lista): soma_lista = 0 for i…
-
-1
votes2
answers60
viewsEncrypt a python string
I wonder if there is any encryption algorithm where it is possible to choose which key or part of it will be used to encrypt/decrypt the message An example: mensagem = 'string qualquer' chave =…
-
-1
votes1
answer53
viewsPassage of variables from one function to another in Python
I’m having trouble passing variables n and m from the starting function to the function computador_escolhe_jogada. The error message itself points: Typeerror: computer_choice move() Missing 2…
-
-1
votes0
answers8
viewsFiltering of shaft information in the Matplotlib Graph
Hello, I’m creating a chart with Python and Matplotlib, using two lists with the same amount of values. My graphic is coming out correctly, but I want to fix the design of it that is not the way I…
-
-1
votes1
answer128
viewsPYTHON - How to pass a parameter?
I’m trying to assemble the game of the copper using python, but I came across a problem that completely blocked my code. I used the Tkinter library and all its functions to create the game, follow…
-
-1
votes0
answers13
viewsEXTRACT LATEST EXCEL FILE INSIDE A PYTHON FOLDER
I would like to know how to tell python(pandas) that I only want to import the latest file you have in a certain folder. Every day the folder is updated with a new file and every day the program…
-
-1
votes1
answer38
viewsPymysql - What is . cursor() for
I am learning database through Pymysql in Python, but many videos only talk about how to do but do not speak because... I wanted to ask what . cursor() in Pymysql is for?
-
-1
votes1
answer1227
viewsPYTHON: Nameerror: name "..." is not defined, but I defined the function
I’m trying to make a little snake game out of Python. I used the Tkinter library and, to register the pressing of a key, I used the bind() function that executes an event after a key is pressed. I…
-
-1
votes1
answer30
viewsGet information inside a dictionary
I’m having a question regarding a dictionary in a dictionary, I have a code that has multiple users on a website,each with a unique name and age, where the names of users and ages are used in keys…
-
-1
votes2
answers52
viewsSwitcher in python with Get
I created a function in Python to return me a name of an object. Before trying to use Switcher I did several variables as below: name_case_1 =…
-
-1
votes1
answer58
viewsProblem to find the lowest value
Good evening, I’m having trouble displaying the lowest value in my code. The statement is: Develop a program to check the student’s grade in a test with 10 questions, the program should ask the…
-
-1
votes1
answer36
viewsFunction does not modify the Matrix after the second call!
I’m making a small game, however, I need to call this function 3 times, in the first call of the function it performs as expected, however, in the second and third call it does not do what I expect.…
-
-1
votes1
answer50
viewschatterbot only delivers a character as response
I’m studying about the chatterbot and in the first training test appeared that he just handed me the first characters as an answer, someone knows explain to me why? from chatterbot import ChatBot…
-
-1
votes1
answer326
viewsDjango: Show report earnings and expenses of a Django management system
I have a management system in Jango and would like to save in one place the report of all winnings (Paid=True), defaults (Paid=False) and expenses of the month or period in Jango admin itself, in a…
-
-1
votes2
answers1396
viewsLoop inside loop While PYTHON
I’m making a program that draws a number from 0 to 5 and the user should guess what it is, but he only has 3 attempts. In case the 3 attempts run out and the user does not guess which is the number,…
-
-1
votes1
answer20
viewsUse IF in Pyautogui in Python (automation)
I am trying to make a piece of a code that it keeps clicking to the side automatically (with automation) and I want when I click certain key it stops working. I do not know what I put in "IF" to…
-
-1
votes1
answer76
viewsLoop repetition does not behave as expected
I’m having difficulty doing an exercise of the book 'Eric Matthes' intensive python course the exercises is as follows: 7.8 - Snack bar: Create a list called sandwich_orders and fill it with the…
pythonasked 4 years, 10 months ago Pedro Moraes Milagres 9 -
-1
votes0
answers18
viewsHello! I need to do two functions: one returning the number of digits of a non-negative integer and the other reversing the number
Finally, I need to print out a tuple. I’m having difficulty with for example the input 30000 return (5, 00003) when it should return (5,3) and the input 103090 returning (6, 090301) when it should…
-
-1
votes1
answer51
viewsDoubt in a Python Exercise
I’m having doubts about an exercise. The program must read two integers called Min and Max. Min can be any value and Max must be greater than min. In then fill in a list with all values divisible by…
-
-1
votes2
answers50
viewsDoes every attribute need advisory methods?
I am learning POO in Python and I was in doubt whether I should use advisory methods for all the attributes I include in a class. For example, if I create a class with 20 attributes, in which values…
-
-1
votes0
answers13
viewsPyformat %s in a string
i have the following line of code to open a browser tab that is passed by the user, but with is the "%s" function since I am not passing any parameter to be replaced in place of "%s"…
-
-1
votes0
answers22
viewsHow do I invert a dataframe?
How do I display this df in reverse order ? I did the inversion by the index, but only the index reversed, the data of the dates without inversion remained in the same position. Basically I want to…
-
-1
votes0
answers48
viewsI have a problem with "if" (Python3)
Well, I was doing a Statistics program (don’t notice the way I wrote I’m new to programming and I was trying to do it using everything I learned from just an introductory course with little…
-
-1
votes1
answer29
viewsHow to remove a value from a set that is inside a set dictionary?
For example, if I have a dictionary like this: { x: { 1, 2, 3 }, y: { 2, 3, 4 }, z: { 1, 5, 6 } } How do I remove all occurrences of 2?
-
-1
votes0
answers37
viewsModulenotfounderror: No module named 'files'
I was using Pycharm in the elaboration of my project and everything was going well. I migrated to Vscode and this problem appeared, and there were no changes to the code. There is something specific…
-
-1
votes0
answers26
viewsHow to display elements in html according to the python flask database id?
This is my view in case you would like to know how to filter what will be shown in the next route for example in the group table has the id and in the table layer tbm according to your id in the…
-
-1
votes0
answers29
viewsFilter list inside list
My question is how to compare my list and filter it. The case would be if, the data entry on my list contains a list, I separate this list. I tried by type(list) but returned nothing. I appreciate…
-
-1
votes1
answer41
viewsHow do I count how many digits, has a result of an operation?
I have an operation that results in some number. Example: 25**7 = 6103515625 The result has 10 digits. I want to run the automatic count of the number of digits of the result in any operation.…
pythonasked 3 years, 2 months ago Luciano titilnoob 11 -
-1
votes1
answer31
viewsnumber of repeated elements of an array
compra = int(input('Valor da compra: R$')) valorPago = int(input('Valor pago: R$')) troco = valorPago - compra dimDisponivel = [100, 50, 25, 10, 5, 2, 1, 0.50, 0.25, 0.10, 0.05, 0.01] print(f'Troco:…
-
-1
votes0
answers28
viewsHow to update a executable
I have an app .exe in python and I need to make this executable check for a new version, and upgrade on the computer. I found solutions like: Rename the current . exe, run the new and delete the…
-
-1
votes1
answer20
viewsIMPORT SPECIFIC EVENT - PANDAS
I have a script where I loop for and run about 330 files, in order to consolidate and apply a filter at the end of the process. As a beginner, I made a few attempts but without success. I want to…
-
-1
votes2
answers47
viewshow to save user’s choice in a Nav-tab modal
I have a modal with some tabs referring to account closure, I need to save the user’s choices, I load types of payments, type of flags etc, each button can have an id, that id I want to save, I just…
-
-1
votes0
answers17
viewsCan someone help me with this python code?
I need to know the functionality of this python function so that it serves what it does and needs to transform it into the PHP programming language. def word_to_int(word): value = 0 exp = 1 for i in…
-
-1
votes0
answers23
viewsIt is possible to make a system that when you press a button adds one more in excel
I am making a system in Python for a bakery at each sale the user clicks on the button and adds one in a certain cell in an excel spreadsheet, I wanted to know how does this system add another…
-
-1
votes2
answers274
viewsHow to resolve character overlays (sprites) on screen with Pygame
I am developing a TOP-DOWN game with several enemies, however, due to the order in which they are plotted on the screen, no matter if one is behind the other, always the one that was plotted last…
-
-1
votes2
answers69
viewsIterations in a tuple list
Good afternoon, I have the following problem: I have a list of tuples called list_chromosomes, with 10 positions. I want to open a new position at the end of it (11th position), where it will…
-
-1
votes2
answers354
viewsImprove python apply performance with lambda
Hello. I am developing a code in python but it is taking time to run, I wonder if there is any other more effective method. Below follows the def that I use def…
-
-1
votes1
answer370
viewsUsing Values from a Dictionary Column to Create a New Column in a Dataframe
I am trying to extract country names from a string type column that I have to create a new column in my Dataframe with just country names. The format is below: ["[{'iso_3166_1': 'US', 'name':…
-
-1
votes1
answer39
viewsProblems with python 3
Good night! I’m having a small problem with python 3.x on my linux Mint 19.03 Code: #!/usr/bin/env python3 #-*-coding: utf-8-*- from tkinter import * win = Tk() def msg(): m = val.get() Label(win,…
-
-1
votes1
answer27
viewsPrint a value inside a buged function
I’m trying to create a program that calculates the bisection method. I would like the user to enter the desired equation and the values of a, b and tolerance, but I’m not getting the equation input…
pythonasked 4 years, 9 months ago Felipe Roque 57 -
-1
votes2
answers86
viewsFormatting multiple float values does not align when the number of digits is different
I am having formatting issues, due to the amount of data that appears on the screen, I try to insert the \t but is bugging. Follows image and code: # Método da Falsa Posição - Cálculo Numérico #…
pythonasked 4 years, 9 months ago Felipe Roque 57 -
-1
votes1
answer990
viewsPython (pyautogui / Selenium) save selected text
Good afternoon! I’m having a doubt here and I’d really like some help: I’m doing some tests here in python, automating the login to instagram, accessing the followers page and selecting the names…
python python-3.x selenium selenium-webdriver pyautoguiasked 4 years, 9 months ago Jonathan Deptulsqui 35 -
-1
votes1
answer304
viewsEntry method in Tkinter, Python
Hello, I was trying to get one the numerical value of the Entry method, I got it, with get(), but when turning to float or int, depending on where this one returns me an error. The way it works,…
-
-1
votes2
answers529
viewsChange array values using for and if
Hello, I have an array with several values. I would like to replace the values above -0.54 to 1 and the values below -0.54 to 0. Below is my results name array: array([-2.06133692, 0.3721 ,…
-
-1
votes1
answer64
viewsValueerror: Classification Metrics can’t Handle a mix of multilabel-Indicator and Binary targets
Hello. I’m creating a neural network to categorize some data. Basically the neural network will tell me which molecule is. This is my code: import pandas as pd from keras.utils import np_utils from…
-
-1
votes2
answers66
viewsHow to input two related items into a Code
usuarios= {'user':[]} senhas= {'senha': []} #Menu cadastro print("Se você já é cadastrado digite (1)") print("Se você não é cadastrado digite (2)") menu= int(input("Digite a opção:")) #Cadastro de…
-
-1
votes1
answer231
viewsGunicorn is not working as it is giving the following error gunicorn.service: Failed with result 'Exit-code'. error
Good night, I made an attempt to deploy my site in Django language, but without success. The errors that came to me after are presented below. I appreciate all the help, because I’ve done a lot of…
-
-1
votes1
answer52
viewsMultiple models - three apps
Good evening dear... my TCC project, has three apps: classrooms, classrooms and allocate. I need to make class allocations in the rooms, after allocated I need to schedule a class boleano as…