Posts by JeanExtreme002 • 5,663 points
331 posts
-
5
votes2
answers1086
viewsA: Adding list elements during a Python loop always returns the same value
This is because while doing append(current) you are not adding a new object to the list but the reference of the same object. When you create a list and assign it to a variable, what you assigned…
-
1
votes2
answers38
viewsA: Deleting item from a list without knowing its index - Python
You can use for loop and check whether the first item in the data list (name) is equal to the name the user entered. If equal, you can delete this data list using the list method remove(value).…
pythonanswered JeanExtreme002 5,663 -
1
votes1
answer38
viewsA: I am not able to solve this error of syntax,
This code block below is unnecessarily indented: if self.discount.kind == "porcent" calc -= calc / self.discount.value elsif self.discount.kind == "money" calc -= self.discount.value end Corrected…
-
2
votes1
answer178
viewsA: Problem when deleting a number from a list!
The mistake IndexError is being generated because you modify inside the block if the size of the list inside the block for. When the program gets a random number, it deletes it from the original…
-
0
votes1
answer92
viewsA: How to save an input to a txt file
Yes it is possible. You can first check if the.txt file exists and if it has any content. To check if it exists just use the function os.path.exists(path). After entering the block if the program…
-
0
votes1
answer1278
viewsA: How to resolve "'int' Object is not subscriptable" error?
The error in your code is being generated because the range returns whole numbers. Soon you cannot get the position of something in it and ends up generating this error. If you happen to mercadoria…
-
1
votes3
answers431
viewsA: What is the difference between float and float[]?
The float is a primitive type of decimal numbers in Java, example: 1.234,5.7,19.3456999. Note that the decimal numbers in Java and in other languages have no comma (,) but a point. In the world of…
-
4
votes4
answers4174
viewsA: What is the meaning of the operator ( * ) asterisk?
The asterisk (*), in Python, it has several features. The first, and most common in most programming languages, is to multiply between numerical values. resultado = 3 * 2 print(resultado) # Imprime…
-
2
votes1
answer430
viewsA: Error "Indexerror: list assignment index out of range"
The problem with this code is that the lists linhas1 and linhas2 have 10 elements ranging from position 0 to position 9 and within the function estacao you call randint(0,10) to generate a random…
-
3
votes2
answers288
viewsA: Make the program go back to the beginning
Use the block while. This repeat block will repeat the code snippet whenever the instruction is true. Soon you can make the code this way: while True: tela=input('Com isso Coloque uma palavra ou…
-
0
votes1
answer56
viewsA: Simple Python gain experience system
The problem is that when you show the amount of XP wins on the hunt you call the hunt() getting a new value. You must create a variable to store the earned value and then add the player’s total XP…
pythonanswered JeanExtreme002 5,663 -
3
votes1
answer227
viewsA: how to return an integer in python? - Python
The problem is that you had to convert the boolean value again to integer. See this code below: a = "101001" def p_not(a): b = [] # Talvez você não saiba disso, mas você pode iterar strings. # Cada…
pythonanswered JeanExtreme002 5,663 -
0
votes2
answers84
viewsA: how to get the element from a list based on another list
You can check inside a block for each element of lista1 and if the element is greater than zero, it will be added together with an element from lista2 in the same position i. See this code: lista1 =…
-
0
votes2
answers801
viewsA: parameter master=None inside the class in module Tkinter (python)
In Tkinter widgets are heirs of a frame, for example, I can create a Button which sits within a Label which sits within a Frame which is inside the window ( known as root or root ). The parameter…
-
2
votes2
answers114
viewsA: A function stores specific elements of a list in another list
This error you presented occurs because the variable pos_el1 shall be created only if if el>=1. That is, if the program does not enter this block, you will try to use a variable that does not…
-
0
votes1
answer90
viewsA: Program that shows the location in a queue
Regarding your problem, this error is being generated because you are trying to import a module called Fila, module that does not exist in your current directory. I also found other errors in your…
pythonanswered JeanExtreme002 5,663 -
0
votes1
answer835
viewsA: Python 3: Tkinter - Background image does not exist, "pyimage1" doesn’t exist
Only the code you showed works perfectly. Certainly, there is much more code from your program that you have not shown. Most of the time, this error occurs when you create one or more windows with…
-
0
votes1
answer784
viewsA: how to improve the time in Python 3 voice recognition?
As far as I know, the only way to decrease recognition time is to have great audio quality. You can improve audio quality using the method r.adjust_for_ambient_noise who receives a source(in your…
python-3.xanswered JeanExtreme002 5,663 -
0
votes2
answers3780
viewsA: How to get the index value of a list in Python?
To fix the problem, first fix the values in your list. Then set the conditional if to find out if sal is greater than or equal to n - 99 and less than or equal to n. If it is, it receives the index…
pythonanswered JeanExtreme002 5,663 -
1
votes1
answer412
viewsA: Set variables with uppercase letter in Python
Generally, uppercase variables are "constants", that is, a variable whose value is not changed in execution. In Python, it is not mandatory to use upper-case variables for this, but many developers…
-
2
votes2
answers1240
viewsA: Recursion to Python List Inversion
A first problem with your code is that the clone will always be reset at each execution because within the function there is the line clone = []. That way, all appends you made will be deleted. To…
-
0
votes1
answer315
viewsA: How do I do a simple math calculation on Tkinter?
The Teste that you are trying to subtract is an object of Entry, it is not a number. If you want to get its value, you must invoke the method get() which will return a string and then convert it to…
-
0
votes1
answer202
viewsA: Use selected path in listdir
From what I understand, your problem is just getting the directory to use on open. So just return the path in the function UploadDir and UploadLista. Example: def UploadLista(event=None):…
-
0
votes4
answers60
viewsA: Array assigned to another does not hold the same value
When you assign directly x = key what you are going through not the object of key and yes the memory address, ie the id of the object. So when you make a change through x you change key because both…
-
0
votes2
answers1157
viewsA: Print the open range between two numbers in descending order
The problem happens because when the variable cont is equal to b + 1 it continues inside the while loop and gets the value of it minus 1 before having its value printed. To solve this problem, I…
-
0
votes1
answer641
viewsA: How to create maximize minimize and close buttons in Tkinter (Python3)
Using only the tkinter I don’t know, but you can create buttons to manipulate windows using the library pygetwindow. See this example below: from tkinter import Tk,Button import pygetwindow title =…
-
0
votes1
answer54
viewsA: Tkinter - set master in another script
You can’t just play a file variable .py running to an imported file. To troubleshoot the problem, you can pass mainScreen as a function argument consume. Example: Second file . py def…
-
2
votes1
answer103
viewsA: Help with simple program of function and sum
Just add the isinstance(n, int) in the first line of its function. The isinstance checks if the value is an instance of a specific type and returns a boolean value. So you can use a conditional…
-
0
votes1
answer132
viewsA: Close Tkinter window after few seconds
Add that line to your code: root.after(ms,root.destroy) Example: from tkinter import * from PIL import ImageTk,Image import os root = Tk() root.overrideredirect(True)…
-
0
votes1
answer132
viewsA: Print Status in a single line
You do. Use the \r at the beginning of your string. What this special character does is replace the text from the beginning of the current line with a new one. Example: import time sprites = ["\\…
python-3.xanswered JeanExtreme002 5,663 -
0
votes2
answers419
viewsA: Python project and Tkinter menu
The cause of the error is that you have not referenced the inserirDados. What you created was not a class method novo rather a function within the method new_janCT. To solve this problem, just…
-
1
votes3
answers168
viewsA: Compare python 'E' letter
Well, you basically need to convert all the names on the list current_users for lowercase. See the code below: current_users = ['zE', 'carmo', 'sofia', 'jeff', 'isa'] new_users = ['ze', 'didao',…
-
0
votes2
answers838
viewsA: How to check if server is available before request.urlopen in Python?
The easiest and easiest way to do this is by using the library requests. Use the function requests.get passing the url you want to check. This function will return an object of Response containing…
-
0
votes1
answer97
viewsA: Nameerror on Django, but the class ta defined
The class Carga is defined in your code after the class VisualizarRomaneio(class that inherits Carga). In Python you can only inherit classes created before. To fix this problem, type the class…
-
0
votes1
answer67
viewsA: Tkinter.filedialog does not work with Toastnotifier
I still can not understand the cause of the problem but doing several tests, I managed to find the solution to my program. The problem for some reason was caused when I passed the parameter thread…
-
0
votes1
answer67
viewsQ: Tkinter.filedialog does not work with Toastnotifier
I am creating a virtual assistant that communicates with the user through notification messages. I researched a lot on the internet about and found the win10toast. So far the program is working…
-
1
votes1
answer545
viewsA: Socket in python
On line 20 where the clientSocket.recv(1024), you did not pass the answer to the variable mensagem. So what was printed was the message you sent and not the one you received. I know it’s not related…
-
1
votes2
answers1177
viewsA: Limit number quantity in an input
Use the function len(seq). This function counts how many elements a sequence (strings, lists, tuples, etc...) has, for example: while True: nums = input(" Digite 3 números:") if len(nums) > 3:…
pythonanswered JeanExtreme002 5,663 -
1
votes1
answer181
viewsA: Use the split() and if method to create a statement that prints the words that start with’s'
You can use the method split to separate the words in this way: string_1.split(" "). After that go through all the words in the list and check that the first element (first letter) is an "s".…
-
0
votes1
answer126
viewsA: Check files that have a certain word - Python (Library os)
You need to open the file contents first and then perform a read by checking if the word you want is inside the file. How to Open Python File ? To open a Python file use the function open(). In this…
pythonanswered JeanExtreme002 5,663 -
0
votes1
answer114
viewsA: Use of map() in python
The map() is a function that returns an iterator object. You need to use it a for loop or convert it to another type of sequence as for example list. See how it would look: import math lista1 =…
pythonanswered JeanExtreme002 5,663 -
0
votes1
answer207
viewsA: To sort the list of tuples in python by value
Welcome to Stack Overflow! First of all, what you have is not a list of tuples, but a list of dictionaries. A list of tuples would be this: lista = [('dia',5),('data',4),('nome',1)] Now that we…
-
0
votes1
answer146
viewsA: How do I run a web routine within Tkinter without crashing the mainloop?
Utilize threads to run parallel processes. See this example: from threading import Thread # Seu código... if __name__ == '__main__' : print ("Servidor: " + subprocess.getoutput('hostname…
-
0
votes1
answer122
viewsQ: Problem when trying to get CPU temperature using WMIC
I’m creating a program for Windows and need to get the user’s CPU temperature. For this task I am using the wmic with the following code in batch: @echo off for /f "delims== tokens=2" %%a in ( 'wmic…
-
1
votes2
answers110
viewsQ: Problems in batch droplet
I am beginner in batch And I’m trying to create a very simple alarm clock program. The user must set the time you want the alarm clock to ring and the program will check the time of the computer. If…
-
1
votes1
answer370
viewsA: Get method error in Python Requests library
The problem is that your file is named as requests py.. The error is being generated because you are not importing the library requests but its module that does not have the function get. This error…
-
3
votes2
answers141
viewsA: Problem in Python3
Error on line 12: You wrote while opcao == 1 or 2 or 3:. On that line you’re not saying "If option is 1, 2 or 3, do.", you’re saying "If option is 1, do it. If not, if 2, do it. If not, if 3, do…
-
4
votes1
answer3554
viewsQ: How to make a Bruteforce in Python?
I’m trying to create a Bruteforce program that can generate passwords with a size x of characters. The problem is that I can’t develop a logic for this. See my code below: chars = getAllChars() #…
-
1
votes6
answers2884
viewsA: music does not play
I had this same problem using pygame and managed to fix it by creating a window through pygame.display.set_mode. For me at least, the mixer only worked after that. Try this code: import pygame…
-
1
votes3
answers629
viewsA: Python: Indexerror: list index out of range
The problem is on line 9 in pilha[-1]. At some point in the implementation of the programme, the list pilha is empty, that is, you are trying to access an item that does not exist, generating the…
pythonanswered JeanExtreme002 5,663