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
votes3
answers79
viewsGreatest prime number
Could you help me with my code? I am trying to get the program to print the largest prime number the user has typed, but my program is printing the largest of ALL and not the largest prime. here is…
-
-1
votes1
answer32
viewsrename rows of a dataframe
I have a dataframe: codcliente contrato 7 1180000007004 7 1180000007003 7 1090000007038 2 1090000007035 2 1090000007029 ... ... 3 2023885638001 3 1073885769001 3 1093885790001 3 1183885847001 3…
-
-1
votes1
answer58
viewsHow do I alphabetize the Telephonic list that is separated between older and younger?
Before making a Phonebook containing name, phone and age, after capturing the data, I need to separate them into older and younger 18 years and print on the screen the result with all the data…
-
-1
votes2
answers45
viewsTkinter and class
I am beginner in classes and Tkinter and am having a problem that I think is by little knowledge of me in POO. In the code below, only one label is running, neither buttons nor anything execute,…
-
-1
votes1
answer87
viewsModulenotfounderror: No module named 'bs4' and cannot access module bs4
I am trying to import the bs4 module into a code and every time I try the following error is displayed ModuleNotFoundError: No module named 'bs4' Theoretically the bs4 module has already been…
-
-1
votes1
answer44
viewsHow to define JSON properties to use in a for loop?
I’m reading a JSON that looks like this: Google Books and trying to display it in HTML. The user’s search input is the seek which is received through the request.form.get down below: import requests…
-
-1
votes1
answer37
viewsExercise - Taking time in seconds and returning to the average and lower values to the average
I have an exercise where it requires that a program be created that receives racing time as input and calculates the arithmetic average of the times spent to travel a daily race course. At the end…
-
-1
votes1
answer37
viewsHow to find a certain value in a line that contains a keyword - python
How could I find a value on a given line that contains a keyword Example (This is the Mirror file) COTIA CENTRO EXTRACT 05978754 ITEM 1 ITEM 2 ITEM 3 MRO: 082545444 I would like to know how to find…
pythonasked 3 years, 5 months ago I Need Coffe 21 -
-1
votes1
answer45
viewsInsert INTO mysql and python error
When I try to make an INSERT INTO in my SQL code, it gives the same error mysql.connector.errors.DataError: 1292 (22007): Incorrect date value: '1998' for column 'validade' at row 1 This is my…
-
-1
votes1
answer45
viewsHow does the sum assignment operator work internally?
I am creating a class and I want its objects to be summed up, using the sum operator or the sum assignment operator. I know that to use the sum operator, we must create for the class the special…
-
-1
votes1
answer41
viewsProblem where I have to create a rectangle without padding, but I’m having trouble with the additional spaces in the rectangle
Hello, I have to make a rectangle without fill, example: digite a largura: 10 digite a altura: 3 ########## # # ##########` But, because of the course automatic corrector, I am not able to proceed…
pythonasked 3 years, 5 months ago Estevan Cardoso 11 -
-1
votes1
answer41
viewsUse modified value within IF in another variable
I have a value condition that is changed within IF and needed to use it in another option called by menu, as I can run? from datetime import datetime print("Bem-vindo usuário!") menu = print('[1]…
-
-1
votes2
answers67
viewsDoes every function need a Return at the end of its execution?
Good morning everyone, I’m starting my studies in python and during the programming of a function that goes in the spreadsheet and transfers the values to a dictionary I came up with a question: All…
-
-1
votes1
answer33
viewsHow to run table algorithm again if user chooses to run again?
from time import sleep print('-=-'*20) print('Tabuada da adição') print('-=-'*20) n = int(input('Insira um número: ')) n0 = n + 0 n1 = n + 1 n2 = n + 2 n3 = n + 3 n4 = n + 4 n5 = n + 5 n6 = n + 6 n7…
-
-1
votes1
answer73
viewsList Comprehension returning zero
Guys, I need your help. I have a code in python that I would like to return the amount of values that meet a criterion, but it is returning zero. The txt file contains data like this:…
-
-1
votes1
answer23
viewsHow to select value from a Dropbox list when site html has no select
Hello! First, excuse my 'technical' little vocabulary, I’m just an adventurer starting Python learning. Regarding my problem, I’ve seen some topics both here and in English but all treat in a…
pythonasked 3 years, 4 months ago Douglas Casavechia 1 -
-1
votes1
answer7
viewsShow text on page from Django database
Hello, I’m trying to display a text from the mysql database, using Django, I’ve searched for several tutorials but nothing works, if anyone can help thank you already. This is part of my file:…
-
-1
votes1
answer30
viewsUnexpected tokens - boostrap4
{% load bootstrap4 %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1,…
-
-1
votes1
answer20
viewsHow to change the color of the text outside of a Tkinter function?
I’m trying to change the color of a text outside of a function with Tkinter. I tried to put the label inside the function but keeps overwriting one text on the other. Follows the code. from tkinter…
-
-1
votes1
answer65
viewsHow to remove n while reading lines from a file
I am making a chart using a CSV file through the matplotlib, but when I print I realize that he gets \n at the end of each line, the question is how I can resolve? My code: import matplotlib.pyplot…
-
-1
votes3
answers74
viewsHow to check how many times the number 2 appears inside a matrix?
My goal in this algorithm is to find how many times the number 2 appears within an 8x3 matrix. My result so far is like this: from collections import Counter import time import numpy as np m =…
-
-1
votes1
answer19
viewsHow to load dynamically staticfiles CSS and Javascripts in Django
I’m writing in Python with Django. As a common practice, I created a "base.html" template that will then be extended by several other pages. Each one will have its own CSS file and its own…
-
-1
votes1
answer15
viewsError in get_absolute_url Django
I have the following error in Django: Reverse for 'list_produtos' with Arguments '(2,)' not found. 1 Pattern(s) tried: ['$'] Follows the codes: py.models from django.db import models from…
-
-1
votes3
answers34
viewsDoubt about converting str to int with py/pandas ((dataset))
I have a column of notes in string format. They come as follows: 432432.0 Always comes with . 0 then I wanted to go straight to int and not to float As ta in this format I saw that I should first…
-
-1
votes1
answer36
viewsPython: consolidate duplicate lines by adding values
I have a spreadsheet in excel format (.xlsx) with the following columns: "matricula", "name", "value", as shown below. I would like to delete the repeated data by adding up the values. The final…
-
-1
votes2
answers32
viewsHow to increase the title font of a Seaborn.displot chart?
Hello! I have the following code: f = sns.displot(df,x="yearOfRegistration", kde=True, binwidth=5) f.set(title = "Distribuição de Veículos com base no Ano de Registro") f.set_axis_labels("Ano de…
-
-1
votes1
answer37
viewsSend Email formatted Python
Good afternoon, I’m in need of some help regarding python and pandas. I need to generate a weekly ranking from some reports I extract from the system, the data I’m able to query but I need me to…
-
-1
votes1
answer40
viewsCheck the existence of a string in a file from another file
I have two files, one is this: gp2,POL-AES-SHA1,Prop-AES-SHA1 gp2,POL-AES-SHA1-PFS-2,Prop-AES-SHA POL-3DES-SHA,Prop-3DES-SHA Note that you can have 2 or 3 items per line (separated by comma). In the…
-
-1
votes1
answer14
viewsModulenotfound when I try to import an external library
pip install pillow >>> Requirement already satisfied: pillow in…
-
-1
votes1
answer61
viewsCalculator in Python
I made a calculator in Python as a practical exercise, I didn’t use functions or research anything, I just did what I know. I would like to know if the code is good, even without the use of…
-
-1
votes1
answer39
viewsHow to do password validation in python:
I made a code to validate the password with some requirements: print("Cadastre aqui sua senha com os seguintes criétios: \n" " *Ao menos 8 digitos\n" " *Ao menos uma letra MAIÚSCULA\n" " *Ao menos…
-
-1
votes1
answer50
viewsHow to identify permutations in matrix columns in C++
In college, I need to do an exercise --- the statement is low --- in which they test with matrices of different dimensions, that is, I need to do a program that reads matrix and writes the matrix…
-
-1
votes1
answer104
viewsHow to create automatic messages by Discord bot with constant updates? (python api)
import discord import TOKEN_value import memes client = discord.Client() TOKEN = TOKEN_value.token() memes_ON = False @client.event async def on_ready(): print('BOT HAS BEEN CONNECTED.')…
-
-1
votes2
answers15
viewsDRF/Django - How to send an attribute value instead of sending a JSON object
Hello, I have an object related to several others, however when I send the JSON, either goes the ID of the related objective or I serializo it and goes the whole object, I would like to send only…
-
-1
votes1
answer18
viewstake top element Selenium, python, scraping
<div class="cell-list-content-icon"> <span><i class="fa fa-briefcase"></i>EMPRESA XXXXXXXX</span> <span><i class="fas…
-
-1
votes0
answers53
viewsProgram that reads 6 EVEN integer values and shows on screen in reverse order
I’m training Python and I’m having trouble with this task: Create a program that reads 6 even integer values and shows on the screen on reverse order. My current code is: lista = [] teste = 0 for i…
-
-1
votes1
answer40
viewsSelenium - No Download Permission
I created a script in Python using Selenium to access a site and download some files, however, the browser blocks the download and informs the following message: "Could not download - No…
-
-1
votes1
answer25
viewsHow to create a directory structure in memory with Python?
Hello. I have the following scenario: I am reading a dataframe, which has a column with Xmls. I am writing these Xmls to files. xml separately, to later save them in a certain folder structure and…
-
-1
votes1
answer34
viewsRender JSON Django field
I am doing a project using Django 3.1.2, this project needs a log. I created a template for logs: class Log(models.Model): Usuario = models.CharField('Usuário que fez a ação', max_length=100) Perfil…
-
-1
votes0
answers28
viewsManipulate a Data frame dynamically
People have a historical series of stock prices in a dataframe and need to create new dataframes of these actions grouped by sector. Dfs must without created and dynamically manipulated, here lies…
-
-1
votes0
answers24
viewsPylance does not recognize libraries in VS Code
I am developing a game with pygame and I feel the need to always see the modules, functions and parameters by the documentation, since for some reason, no suggestion appears when I type…
-
-1
votes0
answers14
viewsHow to insert data into sql without erasing old data?
Hello. I’m learning sql now, I’m trying to make a simple python code to store 4 data in sql database. But every time I stop the code and run it again, it erases the bank and starts again. I couldn’t…
-
-1
votes0
answers17
viewsCreate inputs/selector/radios in Tkinter
Good morning, everyone. I started recently in the games and studies with Python and I’m deepening now with Tkinter to develop some interfaces that interact with the user. I have a code that accesses…
-
-1
votes1
answer22
viewsTkinter starting window before the rest of the programming. (Python 3.9)
Hello, I come to ask for the help of someone more experienced in this matter than myself. I’m trying to use Tkinter and Pyautogui to automate a dull task of my everyday life. My goal is to create a…
-
-1
votes0
answers11
viewsHow to make a url redirect in flask outside of @app.route
I’m trying to consume a free market api using Python along with flask, to be able to use this API, I need to generate a token and to generate a token, I need a client authorization code, ie, will…
-
-1
votes0
answers24
viewsConvert Python time to Dart
I’m making an application for study I took the data from this api https://www.mercadobitcoin.com.br/trade-api/#get_order and I’m converting to Dart. I have the error of {"status_code": 203,…
-
-1
votes0
answers10
viewsError Docker build
Docker build . [+] Building 13.5s (10/11) => [Internal] load build Definition from Dockerfile => => Dockerfile: 32B => [Internal] load . dockerignore => => Transferring context: 2B…
-
-1
votes0
answers21
viewscurve_fit in Python using a column of errors where missing data
I have a problem that I have been trying for days and I can not solve, my intention is to read a file '.txt' that has 3 columns, where the first and the second are the data of the x and y axis, the…
-
-1
votes1
answer29
viewsHow to align side by side the li tag inside the for loop in html flask jinja2?
How do I align side by side the tag li within the loop for in flask {% for g in groups %} <div class='circle'> <ul class="circle-list"> <li class="group"> <a href="/layers">…
-
-1
votes1
answer41
viewsLoop elements in List, Boolean, if condition accepts, create a new list (python)
can you help me? I need to find the companies on the list business1 which satisfy the following condition: the value shown in the last row of the multiple column is greater than 1 at the specific…