Most voted "python-3.x" questions
Python 3 is the latest version of the Python programming language and was formally released on December 3, 2008.
Learn more…3,274 questions
Sort by count of
-
1
votes1
answer59
viewsCommand finddo Matlab in python?
What is the equivalent in python3.6 of command find of Matlab for this expression? The PDF that I have with some equivalences does not have this command pos = find(sn_til>0)…
python-3.xasked 7 years, 1 month ago Sergio Nunes 351 -
1
votes1
answer948
viewsHow to add up the values of an index?
I am new in python and need to make a program that add the digits that belong to the same position of a list, for example: Lista = ['22659', '387685', '89546'] The result of the list sum[0] would be…
-
1
votes2
answers2057
viewspython vector input
I have some input values of a matrix that will have the input of the following form: 1 2 3 4 2 3 4 0 so I’m trying to take the first line of m+n elements to turn everything into float, but it’s not…
-
1
votes0
answers365
viewsReceive user input using Django Class Based Views
If you need more information about the problem (urls.py, complete code of the template, etc.) just ask me to post, just not to pollute the post too much. General description of the problem: Update…
-
1
votes0
answers28
viewsProblem with arguments in connect_signals function
I have read several tutorials and can not find out why the error below is being shown, I suspect there is some problem with syntax. I’d appreciate it if someone could answer: Message:…
python-3.xasked 7 years, 3 months ago J. Angelo 11 -
1
votes1
answer832
viewsCalling Functions in Python 3
Hello, I was "playing" without Python, and I decided to make a minigame, for the PC to play Jokempô with me (I AM BEGINNER IN PROGRAMMING). while pj <5 and pc <5: def game() But I came across…
python-3.xasked 7 years ago Nielsen Rick 159 -
1
votes2
answers4032
viewsRemove specific Python characters
My doubt is the following, in this excerpt of code I am removing a character that specifies with the replace(): lista = [["de carlos,"],["des.dd carlossd,"],["Peixe, texto!"]] lista_separados =…
-
1
votes1
answer754
viewsHelp with While loop in Python
I have tried several times, I can print the largest amount, I can print the date of the biggest sale, my problem is at the time of the loop, code follows the loop as this in command, only when he…
-
1
votes2
answers997
viewsManipulating lists in Python
I have a list like this: Lista_A = [['de','do','da','ou'],['ae','ay','yhh','oo'],['ow','pa','la','for']] How do I leave her like this: Lista_A_new =…
-
1
votes2
answers409
viewsreturning python list indexes
I’m having a problem on the line index, because it does not accept float. But how can I get around it? def median(numbers): numbers.sort()#The sort method sorts a list directly, rather than…
-
1
votes2
answers52
viewsHow to play a list that skips the numbers according to the number typed
Preferably something that explains the answer below (without the spaces) 0 1 4 9 16
python-3.xasked 7 years ago Lucas Souza 567 -
1
votes1
answer57
viewsNumpy delete method doing strange thing
i was testing the delete method of the array class of the numpy library and a strange thing happened: I had the element of Indice 0 deleted from the array, but the element of Indice 1 is deleted. I…
-
1
votes2
answers1032
viewsHow to find the second smallest value of a python array without using built-in functions?
I’m new to programming and I’m having trouble creating a code that returns the second lowest value of a array, ex: array = [2, 3, 6, 6, 5] return 3 I am in that phase of practicing the logic of…
-
1
votes1
answer3096
viewsHow to extract specific data from a Python text file?
I have a **text file of 49633 lines** (txt file) with the following format: -e Tue Mar 28 20:17:01 -03 2017 total used free shared buffers cached Mem: 239956 126484 113472 4904 10292 52280 -/+…
-
1
votes0
answers69
viewsPyqt5 - Mainwindow opens and then closes
main py. (dialog) if __name__ == '__main__': try: import sys from user_interface.ui.login import Ui_Dialog from PyQt5 import QtCore, QtGui, QtWidgets app = QtWidgets.QApplication(sys.argv)…
-
1
votes1
answer4647
viewsHow to manipulate strings with ". find"
I can use ". find" to make the program search for a word within a typed text and say whether it exists or not?(true or false) and what line of text is located, if not, what command do I use to do…
-
1
votes1
answer347
viewsReset variable
I am doing a search on the data anchor SQLITE3 inside my program and it returns values inside my variable, however when I make a condition to be executed for when the value is filled it returns…
-
1
votes2
answers401
viewsHow to display text with multiple lines with format?
I’ve been trying for several lines in a row with one string along with the method .format, but I can’t. a=input("digite algo; ") print("""contem maiusculos:{} contem: {}n\contem números: {} contem…
-
1
votes1
answer436
viewsCapture groups where a specific word appears with Regex
I have the following situation: text_1 = O cachorro correu com o gato text_2 = O carro passou e o cachorro foi atrás text_3 = Sempre que chego em casa meu cachorro pula em mim text_4 = Ele foi…
-
1
votes1
answer40
viewsDjango returning to Valueerror
I am creating a project to send emails, but I am doing some tests and I came across the following problem: The view send_mail.core.views.index didn’t Return an Httpresponse Object. It returned None…
-
1
votes1
answer200
viewsBar chart made in Python became "weird". Any suggestions how to improve it?
Friends, The following chart was generated: The code used was the following: # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import matplotlib.dates as dates from datetime import datetime,…
-
1
votes2
answers153
viewsHow to read 4 numbers at once, and such numbers should be separated only by space?
I made that code but error on 2°line: In this case I did this function to solve a problem that my teacher passed, to know if a student has passed, failed, passed with honors or will take final exam.…
python-3.xasked 6 years, 11 months ago Robert 11 -
1
votes1
answer852
viewspython3.6 URLLIB Request
I have this code: import urllib.request x = urllib.request.urlopen('https://www.google.com') print (x.read()) And the mistake that happens : Traceback (Most recent call last): File "python", line 3,…
-
1
votes1
answer647
viewsProblems with the While Repetition Structure
I’m trying to create a program based on the repetition structure while, but the loop does not end. sexo = str(input('Digite seu sexo:')) if sexo != 'M' or sexo != 'F': while sexo != 'M' or sexo !=…
-
1
votes2
answers400
viewsWhat are the statements placed before strings?
In python, I observed that these "indications" were placed in two cases, first in strings before passing through a hash algorithm, e.g.: import hashlib m = hashlib.sha256() m.update(b"Nobody…
-
1
votes1
answer848
viewsDisplay only hours, minutes and seconds on a graph whose input is in Unix time
Be the Python code that generates a bar graph: # -*- coding: utf-8 -*- import matplotlib.pyplot as plt import matplotlib.dates as dates from datetime import datetime, timedelta x = [] y = [] with…
-
1
votes1
answer1623
viewsSending Server Data to Client (LOCAL)
I have the need to send data from a server function to the client using the library socket but when sending the information to the client they arrive blank, the variable that receives the functions…
python-3.xasked 7 years, 1 month ago Vinicius Silva 11 -
1
votes1
answer647
viewsSelect data from a spreadsheet
I read data from a spreadsheet using Python 3 libraries (xlrd / xlsxwriter / Pandas and Numpy). This spreadsheet has in the rows questions of the survey and in the columns the areas that answered…
-
1
votes1
answer66
viewsProblem with argument substitution in function
I’m having a problem with the arguments I pass in the function below, I’m trying to pass the argument sha512 for hash_type, so that the code within the function is replaced, and so hash_target would…
-
1
votes1
answer554
viewsProblem with reading python files
What is the difference between, make python open and read a file, to pass the read result between áspas? For when I open a file, it contains only the word test and I pass this reading result by a…
-
1
votes1
answer168
viewsPython constructor with **kwargs
I would like to know if the use of **kwargs in a constructor is the best alternative or if there is a better path for similar cases to the one below: class Duvida(object): def __init__(self,…
-
1
votes1
answer495
viewsMultiprocessing with python infinite loop functions
I’m doing a graphical interface with Gtk in python, and I have a serial script that keeps sending and receiving data from a microcontrolled system. The serial script is in an infinite loop (while…
-
1
votes2
answers5286
viewsPut the input data into a list
I need to store the 10 numbers typed by the user in a list, only using "for". for c in range(0, 10): s = int(input()) Then I would just need to know how I store each number after being typed and not…
python-3.xasked 6 years, 10 months ago Lucas Souza 567 -
1
votes1
answer70
viewsProblems with using Return
My code: def a(): print(1 + 1) n = input() print(2) I don’t know how to return only the "n" out of the function to use it with an "if". Ex.: if n in ...…
python-3.xasked 6 years, 10 months ago Lucas Souza 567 -
1
votes1
answer530
viewsFunction returning None when finished
The function, when undoes recursion, returns None, and I don’t know why. def fat(n): if n == 0 or n == 1: return 1 else: return n * fat(n - 1) def superfat (n, x = 1): if n > 0: x*=fat(n) n-=1…
-
1
votes1
answer1748
viewsHow to implement a Python permutation algorithm?
I’m trying to implement a Python permutation algorithm. He receives as input a phrase and a key (numerical value) which corresponds to the number of letters that each group should have, and finally,…
-
1
votes1
answer350
viewsscript search - python
The problem is I can’t separate the arquivo_novo of /root/arquivo_novo, as indicated below. I only need the "new file" to be able to enter the LOOP IF and the system returns /root/arquivo_novo and…
-
1
votes1
answer131
viewsHow to open different web pages using while
I would like the program to perform the repetition of a command 3 times: wait 10 seconds to open a web page. For this repetition to occur I set the code below: import time import webbrowser…
-
1
votes3
answers4541
viewsSyntax error in Python code. What is it?
print("**************") print("Seja Bem Vindo") print("**************") numero_secreto = 65 chute = input("Digite um numero:") print("Você digitou: ",chute) if numero_secreto == chute print("você…
-
1
votes0
answers174
viewsDownload html from python post login screen
Hello, I’m wondering if there is any way to get the url of a site, the password and login strings and simulate a clone to go to the next page (already logged in) and download its source code. Note:…
-
1
votes2
answers3598
viewsImages with Django - exhibition and Static
I’m a beginner in Django and I’m developing a simple blog. I know that the configuration of static files needs to be different for the development and production environment, but I always get caught…
-
1
votes0
answers32
viewsPrevent the user from breaking the program
I would like the code not to break if the user puts a letter in place of a number in the variable: kick. This piece of code works very well if the user adds number, but if you add a letter, it’s…
-
1
votes0
answers708
viewsI need to know how to kill/delete an object
I’m with a program, in which there are some objects, which in this case are "blobs" or round beings, which through ids(identification numbers) can kill each other, but I can’t make the death…
-
1
votes2
answers649
viewsRecursion in Python 3
I’m having trouble organizing a recursive summation formula in Python. I need to calculate: My code: def seq1(n): if n == 1: return n return seq1(n-1)+(-1**(n+1)/n) I keep getting the same error for…
-
1
votes1
answer1939
viewsHow to open, read the file and save in a list of lists the contents of the file using Python
I have a list of paths txt files. With the read() function, I can save the entire contents of the file within a list where each word is stored at a list position. However as I intend to read 3 files…
-
1
votes1
answer309
viewsReturn of python file read function
I did this snippet of code to read through a loop the contents of the list files. lista_nome_base_docs = ['a.txt', 'b.txt', 'c.txt'] tamanho = len(lista_nome_base_docs) print (tamanho)…
-
1
votes3
answers326
viewsDoubt with variables
Hello, I have a question, it seems silly but this getting in my way, I know that in Python you do not need to add a type to variable, example: name = str("Python") but I see some people declaring…
-
1
votes2
answers195
viewsFind the problem in my Python object list
Well I’m asking this question, because I’ve tried several ways, but I can’t find the error in logic or the wrong use of some syntax in python. It would be as follows, I own this class: class…
-
1
votes1
answer31
viewsPq shows this strange result when printing the values defined in class ? (Python)
Guys, I created this class (Car class), then defined the values for each argument of this class. Only when printing the variable with the values already defined, this appears: #isso é o que aparece…
-
1
votes1
answer949
viewsHow to check the type of elements in a Python list?
I have a list of data, and I need to verify that all elements are integer or string, or any other type of data. It is possible to verify all elements or needs to be one by one? For example: Lista =…