Posts by JeanExtreme002 • 5,663 points
331 posts
-
2
votes1
answer352
viewsQ: How to separate the name of packages in the Intellij IDEA directory tree?
I am using Intellij IDEA to program in Java and want to create several packages inside each other, where each of them will contain classes and other file types. The problem is that when creating…
-
2
votes2
answers96
viewsA: Why does readlines display an empty list even with the file having data?
The methods of reading read(), readline() and readlines() perform the reading of the text only once, or better, perform the reading of where they have stopped. file.read(3) # Lê até o 3º caractere…
-
1
votes1
answer203
viewsA: How to name the indexes of an array of arrays according to another array?
It is not possible to "name" lists because they only work with positions. What you may be looking for is called dictionary, which is an object in which it has a key and a value. Using dictionaries,…
-
2
votes2
answers487
viewsA: How to use the return of a function in another Python function
To do this, it is not enough to create a variable within the function, since you would be creating a local and not global variable (see this reply who speaks on the subject). To use the function…
-
0
votes3
answers224
viewsA: Variable becomes string without reason
First of all, I’d like to say that in programming, nothing happens out of nowhere like magic. If something didn’t go as expected, it means there was a bug caused by some programmer. That being said,…
pythonanswered JeanExtreme002 5,663 -
2
votes3
answers165
viewsA: Error with Random function
That’s what you get is not a mistake! This is the literal value of your function that you get through the code below: >>> v = randint.__str__() # Devolve uma string >>> print("\n"…
-
0
votes5
answers3780
viewsA: I want to know how many rows and columns an array has in Python?
The problem with your code is in the second loop for. What happens is that you count the number of columns, based on the number of rows. The result worked in this code using this matrix by pure…
-
1
votes2
answers1775
viewsA: How to remove all elements from a javascript div?
To remove all elements, you must go through the child elements through a loop for, removing them with the method remove(). See the example below: function removeAll(){ const div =…
-
1
votes1
answer39
viewsA: Sum several inputs
The problem is that you initialized the variable soma with a array, when you should initialize with a number (in this case the number zero). See below for what your code should look like: function…
-
1
votes0
answers66
viewsQ: How to get the key from a keygen?
I have an HTML document with a form and I want to send a random key to the server. To do this, I’m using the element <keygen>. Before the data is sent, I need to get the value of this element…
javascriptasked JeanExtreme002 5,663 -
2
votes1
answer79
viewsA: How to replace/replace array keys
Just go through your key array and go adding each key and value into a new object. That way: let dataHead = ['nome', 'segundoNome', 'priSobrenome', 'segSobrenome']; let dataBody = {'0': 'Ikaro',…
javascriptanswered JeanExtreme002 5,663 -
5
votes2
answers74
viewsA: What it really means "from modulox import *"
Use the asterisk (*) will yes import all data (variables, functions and classes) from the module you specified in from, having no other purpose. What happens is that by doing from tkinter import *,…
-
2
votes3
answers289
viewsA: How to print a Python operation by adding zero to the left?
It’s impossible to get the value 02 in the form of float or int, because in Python and even in your own calculator, the value 02 will be converted into only 2. To add zero to the left, you must turn…
pythonanswered JeanExtreme002 5,663 -
1
votes1
answer31
viewsA: Hi, I’d like to do a Progressbar with Tkinter, can you help me?
The problem is you didn’t put underline double in the builder’s creation. What you did was put _init_ when should I put __init__, thus the program never entered the method. Another mistake you made…
tkinteranswered JeanExtreme002 5,663 -
1
votes1
answer57
viewsQ: I’m not able to create array with keys in Java
I am studying the Java language and to practice I am creating a simple login program. I have a class called Database that should save an array with the information (name and password) of the users.…
-
1
votes2
answers973
viewsA: How to export and import object array in Javascript?
The easiest way to import to Node is by using the function require(path), exporting the object through the attribute module.exports, thus as follows: Archive that exports: // Atribui a…
-
3
votes2
answers1637
viewsA: How to print 4 triangles patterns next to each other in Python?
It’s very simple but I had to write everything from scratch because I couldn’t reuse your code. What you need to do is scroll through each line of the drawing that will appear, formatting the string…
-
0
votes1
answer126
viewsA: Print with python counter 3
All you need to do is create an auxiliary variable to count and increment it within your function, so that the count increases with each call. See the example below: contador = 0 def…
python-3.xanswered JeanExtreme002 5,663 -
3
votes2
answers1231
viewsA: How to add text to a specific line in Python txt file?
First you need to separate each line from your file. To do this, use the method readlines which will give you a list of all the separate lines. After that, simply insert the text you want with the…
-
3
votes2
answers113
viewsA: Encapsulation of functions
When you say "encapsulate function," I believe you’re talking about nested functions. To do this, just put your function gera_nums() inside extrai_maior() and define the so-called function within…
-
1
votes3
answers122
viewsQ: How to obtain the contents of an HTML element from a Regex string?
I am creating an application that reads the content of a page on the internet and then gets the text of an element <textarea> of that content. To accomplish such a task, I decided to use…
-
0
votes3
answers46
viewsA: How to modify a repeat
To perform this task, you need to create an auxiliary variable to count the number of laps the program has performed in the loop while, this way, you can verify when the amount of errors reaches 10.…
pythonanswered JeanExtreme002 5,663 -
0
votes2
answers66
viewsA: How to input two related items into a Code
To relate the data, just use the function zip passing as parameter the values that are inside your lists. See the example below: usuarios = {"user": ["Gabriel", "Vanessa"]} senhas = {"senha":…
pythonanswered JeanExtreme002 5,663 -
0
votes3
answers362
viewsA: Functions with optional Python parameters
You must use * to pass unlimited values as parameter or else keyword Arguments to set a key and value. After that, you would need to manage past arguments, as in the example below: def…
-
1
votes2
answers75
viewsA: I’m trying to put the current time in an HTML and Javascript project
There are a number of problems in your code that makes the time is not inserted in your element. First of all, to get the document elements, you must use document instead of Document. Also, on the…
javascriptanswered JeanExtreme002 5,663 -
10
votes1
answer231
viewsQ: How to use IBM Cloud services with POST request in Python?
I am trying to use IBM Cloud’s "Speech To Text" service in my Python application via POST requests with the package requests. The problem is that I am confused about the URL that should be used and…
-
1
votes2
answers126
viewsA: Adding elements to a dictionary only if the key does not exist
Just place the assignment of notes inside the block if and use a not before to check if the student is not registered. Nor is it necessary else since anyway, the dictionary will be returned. See the…
pythonanswered JeanExtreme002 5,663 -
3
votes1
answer82
viewsA: Errors when defining the edges of an N x N matrix? Index: list index out of range
The problem lies in the logic of your function. First of all, you do not restart the variable col after you’ve run the line. The consequence of this is that the variable will be incremented to a…
-
5
votes0
answers345
viewsQ: API googletrans mistranslating texts
I am trying to create a Python application where I need to translate some texts, and to perform such a task, I am using the API googletrans. text = 'Back in the day people used to go to many…
-
2
votes1
answer36
viewsA: How do I convert this Object
It is not possible to "convert" this object the way you think, but it is possible to get the result you want by getting the attribute value company thus: const objeto = [{company:…
javascriptanswered JeanExtreme002 5,663 -
1
votes1
answer49
viewsA: How to organize the output that Python returns in the Pymongo module?
What you get is a list of Databases names, so it’s normal for the object representation to come with brackets and commas. If you want to have a different output, you can go through all the names in…
-
1
votes2
answers529
viewsA: Change array values using for and if
Just like you said, in your code the for traverse each element of the array, assigning each loop an element of the array to the variable resultado. The problem is that when using the operator =, you…
-
1
votes1
answer33
viewsA: How do you show only half the content the camera picks up?
Just get the image size using the attribute shape and then crop the image using slice (your image is an object of numpy.ndarray, which is a kind of list). See the example below: import cv2 camera =…
pythonanswered JeanExtreme002 5,663 -
2
votes1
answer85
viewsA: How to take the links of a Nav with Javascript and add a class?
On your first attempt you only managed to change from the first element of the list because the querySelector gets only the first found element of the document. To get all the elements you must use…
-
3
votes2
answers767
viewsA: Dynamically add images with Javascript
To create elements dynamically in Javascript, just use the function createelement passing the name of the tag you want to create as argument (in this case it is the tag <img>). After you have…
-
0
votes2
answers50
viewsA: Trying to print the total sum of all values within the list?
There are many problems in your code and one of them is that you use the operator in instead of the operator of. The in is an operator that will traverse the attributes of an object and not its…
javascriptanswered JeanExtreme002 5,663 -
0
votes1
answer46
viewsA: How do I print a table with all iterations in Python?
You can use a loop for to go through all the answers and print them, like this: for resposta in resp: print(resposta) In this case, you will print each dictionary contained in the list. If you want…
pythonanswered JeanExtreme002 5,663 -
4
votes2
answers162
viewsA: Join of lists in Python
Just use the method extend to merge a list with another. See the example below: lista1 = [[1, 0, 0, 0], [1, 1, 1, 0], [1, 0, 0, 0]] lista2 = [[1, 0, 1, 0], [1, 0, 1, 1]] lista1.extend(lista2)…
-
4
votes1
answer536
viewsA: How to check if a string is inside a string set?
I didn’t quite understand the "use string as value" part, but rather it is possible to check whether a string is inside a list, tuple and other iterable. In your example code, the comparison…
-
1
votes1
answer35
viewsA: How to invert a shape in Tkinter
Just change the position x from the tip of the triangle to have its value added to the width of the triangle and subtract the positions x the other coordinates by their width, thus: forma =…
tkinteranswered JeanExtreme002 5,663 -
3
votes1
answer77
viewsA: Error saving an image obtained by Opencv
The problem is that you are not using a separator between the directory name and the file name. What your code does, is join the nome with the framesObtidos to form a single filename. See the…
-
0
votes1
answer90
viewsA: problems with IF and ELSE
Just put your code inside a block while passing some instruction or using the break to exit the block and proceed with the code. See the example below: nome = input("Qual é o seu nome? \n") while…
-
2
votes1
answer298
viewsA: Doubt about toString Java method
Sasaki you are quite wrong about using the method toString. To print something on the console you must use the method print as you yourself did in the code of your question. The method toString is a…
-
3
votes2
answers437
viewsA: Regex to find text between square brackets
The problem is that in your string there are brackets, which are special characters in regex, as you can see here in documentation. To solve this problem, you should remove these brackets from your…
-
0
votes0
answers125
viewsQ: VCRUNTIME140.dll was not found running cx_freeze executable
A few days ago I developed a Python application and managed an executable using the package cx_freeze with the following code: from cx_Freeze import setup, Executable setup( name = "Minha…
-
1
votes4
answers2542
viewsA: Access list element within Python list
In the same way that you access an element within one-dimensional, you also access it in a multidimensional list. To access an item within a list, you would write the following code: lista[indice]…
-
1
votes1
answer563
viewsA: Replace blank data in a list (Python)
To replace the value just get the position of the element in the list and through the index, pass the new value that will be obtained through the input. You even had a good idea, only you ended up…
-
1
votes1
answer990
viewsA: Python (pyautogui / Selenium) save selected text
There are many ways to get the content copied in Python, one of them being the package pyperclip. This package has two very interesting functions that are the copy() to copy a text and the paste()…
-
3
votes4
answers1011
viewsA: Replace a string’s letters with their respective alphabet position
To replace the letter with the position of the alphabet, just get the position of the letter in the Array with the method indexOf and add +1 since the elements in an Array start at zero position. To…
-
1
votes2
answers86
viewsA: Formatting multiple float values does not align when the number of digits is different
The character \t works perfectly, what happens is that the data can have different sizes and the spacing should suit this difference. What you can do there is create a code to set a fixed size for…
pythonanswered JeanExtreme002 5,663