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
votes0
answers56
viewsI was running Py on Vscode for the first time and this message appeared:
I tried to run a py code on Vscode. print("Olá Mundo") And there was this message on the terminal: ( Python not found; run no arguments to install in the Microsoft Store or disable this shortcut…
-
-3
votes1
answer45
viewsDuplicate files
Good Afternoon, I’m very new to Python (2 months) and this is my first post here! I’m creating a script that helps me read two files: -- 1 file with 51 lines (each line has a different TSAT113806)…
-
-3
votes0
answers13
viewsError in python compiler
nota = int(input()) if nota == 0: print('E') elif nota >= 1 and nota <= 35: print('D') elif nota >= 36 and nota <= 60: print('C') elif nota >= 61 and nota <= 85: print('B') elif…
-
-3
votes1
answer28
viewsI do not know what to do, I’m making a table of results for an exercise and says that is giving error in line 4
a = input ('Primeiro número: ') b = input ('Segundo número: ') c = a+b d = a-b e = a*b f = a**b g = a//b h = a%b print('a = ' , a , '\nb = ' , b , '\na + b = ', c , '\na - b = ', d , '\na * b = ', e…
pythonasked 3 years, 2 months ago Alejandro Figueiredo 1 -
-3
votes3
answers224
viewsVariable becomes string without reason
I made a program where one should guess a number, and in the end it works normally, but I ended up encountering a somewhat strange event. In the code I transform a string with a number inside, in a…
-
-3
votes1
answer48
viewsPyhton move files according to quantity
I’m trying to create a script that: Move from a source folder to a destination folder 9 files that start with '_A_'. Obs: Inside the source folder there will be dozens of files starting with '_A_',…
pythonasked 4 years, 7 months ago hanspereira 1 -
-3
votes1
answer54
viewsResult is always 404, but the records exist. Where can the error be?
POST /sinalizar_interesse/9/3/ means that 9 is interested(a) in 3. Code: def localiza_id(id_usuario): for pess in database['PESSOA']: if pess['id'] == id_usuario: return 200 return 404…
-
-3
votes2
answers54
viewsLoop to find correct combination
I recently built a simple algorithm to find correct combinations with the following url:…
-
-3
votes1
answer142
viewsPrototype of python application
Guys, I have a lot of work to do on creating a prototype of these parking apps, and I’m kind of new to programming and I’d like to know what I could improve on these coding lines: telaInicio =…
-
-3
votes2
answers136
viewsWin function in Tic-tac-toe - Python
Hello! Facing the construction of an old game in Python, I’m doing a victory function, which will alert which of the players won the match. Below is the game algorithm under construction: def…
-
-3
votes1
answer98
viewsProblems with Matrices - Python 3
1 - Read a matrix D 5 x 5 (consider that duplicate values will not be reported). Then read an X number and write a message indicating whether the value of X exists or NOT in the matrix. 2 - DESAFIO…
-
-3
votes2
answers77
viewsDoubt about lists and repetitions ! (Python)
Hello, I am doubtful in a matter of a list of Algorithms, it asks to create an algorithm where the user informs a certain amount of numbers and for when he type 0. At the end of the program he wants…
-
-3
votes2
answers89
viewsrecursive exchange
''' Implement a recursive troca_recursive function she gets a list and two numbers (take and put) and returns the list, changing the number take by the put The first test takes the "simple case":…
-
-3
votes1
answer215
viewspython compiler
Good afternoon, I am developing a virtual assistant in python, which by voice command is possible to do some things. When the script in Pycharm or the same works smoothly, when running cmd on…
-
-3
votes2
answers1618
viewsDate conversion problem (DD/MM/YYYY to YYYY-MM-DD) with 'pd.to_datetime()' - Python
I’m starting in the world of Python and I’m trying to develop a simple code to identify the expiration period of digital certificates where I work (it’s a personal project, but taking advantage of a…
-
-3
votes3
answers65
viewsEternal and unique value
That’s not a problem, it’s a question, so I hope you can help me. I’m a beginner in python, and I’m learning about lists, and the teacher talks about unique, timeless elements. I wanted to know the…
-
-3
votes2
answers72
viewsPython does not advance and does not present an error after converting string to float, how to resolve?
I’m getting the string 24.120185722369005 from a MQTT(Hivemq) topic, but when converting to float, it ignores the rest of the function. def on_message(client, userdata, msg): temperatura =…
-
-3
votes1
answer75
viewsWhen executing the code below, a "Syntax: invalid syntax" Syntax error appears. I cannot identify the error
from math import pi, sin, cos from math import sqrt, acos, log, exp def d_rsc (Z, p, Td, Rsea, Rstab): m = 35 * sqrt ((1224 * ((cos (Z))**2) + 1) TRTg = 1.021…
-
-3
votes1
answer53
viewsPython Flask Typeerror: 'Nonetype' argument is not iterable
I have a Web Application that uses Flask that was working right only it is now returning me an error. The application does a search in the name of the players in a json file, in the execution of the…
-
-3
votes1
answer33
viewsWhen I run the error appears: "Car() takes in Arguments". Can anyone help me? I don’t know what I did wrong
class Car(): """Uma tentativa simples de representar um carro.""" def _init_(self, make, model, year): """Inicializa os atributos…
-
-3
votes1
answer563
viewsHow to make python code run again after running something?
So I’m not very experienced in python and I was trying to do a terminal program to organize books.. follows a part of the code: #sql import sqlite3 con = sqlite3.connect('teste.db') cursor =…
-
-3
votes1
answer57
viewsAdd the integer value of one list to another. EX: [9,9,9]+[0,0,0,1]=[10,0,0,0]
All right, everybody?! I’m having trouble implementing something like (in python): I have lists, for example: Lista1 = [9,9,9,9] Lista2 = [0,0,0,1] I want a date with something like: [10,0,0,0](list…
pythonasked 4 years, 1 month ago Jordan Zitzke 11 -
-3
votes2
answers213
viewsGenerate a list of prime numbers up to 1000. These numbers should form a list, Lprimos. then check in Lprimos whether it is prime or not
I created an algorithm that prints the list, but I’m having difficulty doing the repetition that does the list search, I’m using if X in List, but I’m not getting it, someone could help me? The…
-
-3
votes2
answers104
viewspython vectors, help out?
I don’t know where I’m going wrong,. Make a program that reads a vet vector of 20 integers. The program must generate, from the read vector, another pos vector containing only the positive integer…
-
-3
votes1
answer323
viewsCreate dataframe pandas by dicionario 1 key and 1 value
How do I create a Data Frame Pandas through a dictionary counting only 1 key and 1 value dic = {'banco': 0, 'correndo': 1, 'da': 2, 'de': 3, 'depois': 4, 'descasnando': 5, 'foi': 6, 'ladrão': 7,…
-
-3
votes1
answer55
viewsOnly json content between []
I have a question about a code I made using scrapy to collect data and send to a json file. The problem is that the file formatting is not as it usually is, so I found it strange, I’m in doubt if…
-
-3
votes1
answer177
viewsPython multiplication using recursion without interactions of type `while` and `for`
I’m writing a multiplication calculator code that should use only arithmetic operators in the range of -10 >= x <= 10 and should always do the math under the best possible performance, ex.:…
pythonasked 4 years ago Matheus Esteves 61 -
-3
votes2
answers113
viewsLargest item in a shopping list
I need to find the most expensive item within a list. The entry must contain the product code, quantity and price entered by the user in the same row in that order and each row is a product. Then…
pythonasked 3 years, 11 months ago Nathalia Souza 11 -
-3
votes1
answer242
viewsUnable to Import csv file into pandas
Good guys, I’m trying to import a csv file into pandas through the code below: import pandas as pd data = pd.read_csv('pop.csv') He can’t find the file under any circumstances! Note: The file is in…
-
-3
votes1
answer895
viewsHow to traverse the string by words or by letters?
Code: while True: regras, numero_frases = map(int, input().split()) if regras == 0 and numero_frases == 0: break dici = {} for r in range(regras): subs = input().replace(' ', '').split('->')…
-
-3
votes2
answers167
viewsPython library installation error by cmd
I am wanting to install the pywhatkit python library by cmd, but when I put the " Pip install pywhatkit" command it downloads and installs to some extent. Follow the information that appears in cmd:…
-
-3
votes3
answers71
viewsYou are not printing string
Good morning, someone can help me? It is intended to develop the function invert_pal(st) it takes as parameter a string st and returns as a result the same string in which each word was inverted.…
-
-3
votes1
answer71
viewsSum values of a string by assigning values to letters (Python)
Goal: Assign values to a string based on a dictionary with keys and values Example: I have a string in this format: str = 'ABCD' and a dictionary in this. dic = {'A' : 71, 'B' : 103, 'C' : 115, 'D'…
-
-3
votes1
answer43
viewsRead file and count repeated elements
Hey there, guys. I need some help solving a cucumber quickly. At work I have a file that has 18 characters per line (more than 600 lines). I need to read each line and in each line read 6 characters…
-
-3
votes1
answer82
viewsI want to return the exact same words but I don’t know how to do it
I have a problem that when I try to return the words I intend it also returns the words that have a comma or any character. For example, "I have this phrase that serves, to serve and that serves[1]…
-
-3
votes1
answer84
viewsCreating a Register Program with Pandas and Python
I’m creating an expense control to be used as a data science study. This is my expression: def cadastro(): descritivo = [] valor = [] condicao = [] mes = input('Qual o mês vigente: ')[0:3].upper()…
-
-3
votes1
answer94
viewsHow to extract specific data from a python text file and store in a variable
Good morning, I have a text file with more than 2mil tax coupons , but I wanted to extract one by one for the value, for now my code is like this: import re txt = open("arqEspelho.txt", "r") x =…
pythonasked 3 years, 8 months ago jsales1990 3 -
-3
votes1
answer48
viewsPython - List Creation
I am not being able to print the data table, it is only giving the data of the first input, and I could not see where the problem is, I am beginner and making simple projects. print…
-
-3
votes1
answer48
viewsPython - Number analysis program
Come on! I’m trying to do a program exercise, where the user will give the amount of numbers he wants to be checked, what are the numbers, and if he wants the highest or lowest, number between them.…
pythonasked 3 years, 8 months ago otavio_france 1 -
-3
votes1
answer87
viewsPython - List sorting without Sort()
I was studying this list ordering code and there are some things I didn’t understand: Why is it necessary to break? Why leave the else ident with the if and without the break doesn’t work? Why with…
-
-3
votes1
answer125
viewsPYAUDIO INSTALL ERROR
To use Speech recognition with microphone, I need to install Pyaudio, more when running the installation pip install pyaudio I get the following error: Collecting pyaudio Using cached…
-
-3
votes1
answer1234
viewsCreation of two dictionaries from a dictionary with one criterion
Read and store in a dictionary the name, age and phone number of your contacts, the key being the name. When typing an empty string for the name, the program stops reading and closes. Display the…
-
-3
votes1
answer89
viewsYou are giving variable not defined within an if
Art. 42. Can adopt the over 18 (eighteen) years, regardless of marital status. § 1º Cannot adopt the ascendants and the brothers of the adopting. § 2º For joint adoption, it is indispensable that…
-
-3
votes1
answer81
viewsFacebook Json - Problems with accentuation - Python
I’m trying to import the Friends.json file from Facebook, but I’m having trouble accentuating it. Friends.json file is something like: { "friends": [ { "name": "Marco Aur\u00c3\u00a9lio Ferreira",…
-
-3
votes1
answer52
viewsThe . append() is not working in my dictionary - Python
Hello, my problem is this: I have a dictionary called People: pessoas = {} that allows me to register the name and age of the person. I made a input asking how many people the user would like to…
-
-3
votes2
answers44
viewsPrint all if conditions
I wanted a way that when the user typed the key = 4, all the conditions I assigned were printed, have some mode or I would have to assign an if condition and repeat everything again? import math…
pythonasked 3 years, 7 months ago Pedro Tigre 1 -
-3
votes1
answer136
viewsFunction within a Python dictionary
I am trying to perform an exercise where when creating a log file dictionary whose key is returned a random number between 100 and 9999 as enrollment as follows from datetime import date, time,…
-
-3
votes1
answer65
viewsScript that is in Javascript for Python
am with the following Javascript function: function main() { let data = fazGet("https://economia.awesomeapi.com.br/json/all"); let moedaJSON = JSON.parse(data); console.log(moedaJSON) const keys =…
-
-3
votes1
answer44
viewscomp make that a variable of a database has the total of records that another bank owns?
opa, me nome antonio, I’m starting in December, I’m creating an application where I need the totmatérias attribute of the table "Writer" to have the number of news written by that writer that is…
python python-3.x django web-application django-templatesasked 3 years, 7 months ago Antonio Pacheco 27 -
-3
votes1
answer44
viewsHow can I use python with c++?
I found that I can use two programming languages in the same program, but I don’t know exactly how to do this... I just wanted an idea in a very simple example to make the code work below and I…