Posts by Augusto Vasques • 15,321 points
571 posts
-
2
votes5
answers10407
viewsA: Identify if there is an uppercase letter in the string
A possible solution would be to iterate through the characters in the string and ask what their Category General Unicode via the standard library function unicodedata.category(). In this case the…
pythonanswered Augusto Vasques 15,321 -
0
votes2
answers70
viewsA: I need to make a button that gets the values that are inside a td
Quick response: var id = $(this).parents('tr').find('[produto-id]').attr('produto-id'); It is not clear in the question, but it suggests that: has a table. in each row of this table there are two…
-
3
votes1
answer47
viewsA: Why is getElementsByClassName not working?
As said in the comments the method Document.getElementsByClassName() returns an object array where you must iterate to work with individual elements. In javascript there are several ways to iterate…
-
1
votes2
answers70
viewsA: The created element does not take javascript functionality
All that was left was to register the events dragstart, drag and dragend next to the new card created in function creatCard(), the existing code only records these events to the cards created on…
-
1
votes6
answers342
viewsA: Get a list of the first multiples of a number
You can also do using the module itertools that has some interesting functions to work with iterators. Python iterators are simply objects that can be traversed one element at a time. For this, they…
-
2
votes3
answers114
viewsA: How to remove only spaces between words/letters?
It is possible to create a regular expression that captures only the spaces contained between two characters. import re regex = re.compile(r"(?<=\w)\s+(?=\w)") print(regex.sub("", " p s i c ó l o…
-
1
votes2
answers177
viewsA: How to find the umpteenth occurrence of a substring?
You can use the builtin function enumerate() that returns a list tuples containing a count of the iterable passed as parameter where in each tuple the index 0 is the position of the element in the…
-
1
votes2
answers59
viewsA: Apply equal properties to different JS objects
Yes it is natively possible to cause different instances in javascript may have one or more linked properties in such a way that the change of one of these linked properties in any of the…
-
3
votes2
answers329
viewsA: Function that returns uppercase consonants
An alternative may be the use of the method str.translate() which returns a copy of the string in which each character was mapped through the translation table. This translation table can be…
-
7
votes3
answers211
viewsA: Problem where IF and ELIF do not work in Python
Problem: The flow of your code will always fall into print("StreamShop,","R$89,99"). That’s because on the line... if x.lower() == "verão" or "verao": ...is being instructed to the program to carry…
-
9
votes3
answers228
viewsA: Compare two lists in python and return matches
Convert the lists to ensembles and make the intercession &: uma_lista = [1, 2, 3, 4,] outra_lista = [3, 4, 5, 6,] print(set(uma_lista) & set(outra_lista)) resulting: {3, 4} Test the code on…
-
4
votes4
answers167
viewsA: How to return the first vowel of several words in a list?
An alternative is to apply a filter to your strings allowing them to pass only the vowels and collect the information. The idea of the algorithm is to check every word of its tuple and do a search…
-
3
votes3
answers179
viewsA: Basic Python repetition - doubt in "and" and "or"
Complementing what has already been said, the logical operator or returns True one of its premises being true and the logical operator and returns True only when both premises are true, here are the…
-
1
votes3
answers71
viewsA: You are not printing string
Every time you solve a problem first thing you should do is decode the proposed message for the purpose of finding out what is being required. In this process do not be afraid to highlight the text…
-
3
votes1
answer189
viewsA: Separating a String without defined delimiter
As stated in the comments use the function substr() to return a part of a string. This function has the following signature: substr ( string $string , int $start [, int $length ] ) : string Where:…
-
4
votes3
answers418
viewsA: How to write a function that takes 2 integers as a parameter and returns the largest of them?
If you cannot use builtin max that returns the largest item in an iterable or larger than two or more arguments.: >>> max(3, 4) 4 Compare the arguments to decide which one is bigger and…
pythonanswered Augusto Vasques 15,321 -
3
votes3
answers87
viewsA: Working logic error with list
Consider this introductory reading: Python is a highly object-oriented language. In fact, virtually all data items in a Python program are objects of a specific type or class. Consider this code:…
pythonanswered Augusto Vasques 15,321 -
4
votes1
answer65
viewsA: Replace strings with list elements
Just replace the column in Dataframe. Avoid using the identifiers of builtins of language as variable names. Example: import pandas as pd l = list(range(100,103)) df = pd.DataFrame({…
-
1
votes2
answers248
viewsA: Checking repeated character in Python list
To search for the occurrence of a character pattern in a string use a regular expression. The pattern (?P<char>.).*?(?P=char) means: (?P<char>.) setting up a catch group, identified as…
-
2
votes1
answer180
viewsA: C# Generate random and unique number, check the database if any equal number has already been generated and if you have to generate another number again
As I said in the comments : The coupon number you will always have to create, randomly as specified, but making the table column have the restriction UNIQUE DB itself prevents you from adding a…
-
4
votes2
answers234
viewsA: Error "Maximum recursion Depth exceeded" when implementing Setter
Answering your question the error message informs that one of the attributes of your class Produto is in loop auto updating recursively. Paying attention to the error message: File "C: Users levil…
-
2
votes3
answers2361
viewsA: Remove URL parameter with Javascript
In modern browsers this operation can be done with the help of the interface URL, Internet Explorer should still use the polyfill. Behold Compatibility table with the browsers. The interface URL…
-
1
votes1
answer38
viewsA: Problem To Overwrite Value
I made some modifications to the code: I have mastered the local function valorIcms() to become a base class method Cliente, because the way it was declared was a local function belonging to the…
pythonanswered Augusto Vasques 15,321 -
3
votes2
answers73
viewsA: How to find strings within an array
Use the method Array.prototype.filter() to create a new array with all the elements that passed the given test in a function passed as parameter to filter(). To implement the test use the method…
-
2
votes3
answers415
viewsA: How do I timeout and replay a command line in Python?
One solution to your problem is to use the module asyncio. asyncio is a library for writing concurrent asynchronous code using syntax async/await. asyncio operates on corroding which are a more…
-
4
votes1
answer161
viewsA: Output composite structures in Python in Google Colab
This happens because the resource of printing beautification is activated. The Google Colab Notebook is a web application that lets you write Python code in your browser. The laptops of Colab allow…
-
1
votes1
answer30
viewsA: How to prevent a grid-item from changing size when adding text?
An immediate possibility is to replace the <div class="result"> by a <textarea>. function caesar(message, key, mode) { let translated = ""; for (s of message) { translated += mode ==…
cssanswered Augusto Vasques 15,321 -
1
votes3
answers166
viewsA: how to find the indexes of an item that repeats in a list in Python
An alternative is to build a dictionary that stores in the keys the distinct items of the input list and in the values a list with occurrence indexes of their respective keys in the input list and…
-
3
votes3
answers105
viewsA: Find and change specific Python dictionary
If the list of entries is a short list and only one search being done in this list the other solutions in linear time, where the codes iterate all the data at each query, solve your problem. But if…
-
2
votes2
answers72
viewsA: Why does "0" not appear? Once the logic of "do while" is: do yourself then check
Every mistake is made on this premise: ... (remembering that he enters from the 9 in do while then I don’t know why there’s a 10 there... Wrong, the variable $valor enters into the loop of the-valid…
-
2
votes4
answers241
viewsA: Filter list of python objects
The built-in function filter(function, iterable) is defined as such in the language manual: filter(function, iterable) Build a iterator from the elements of everlasting for which Function returns…
-
4
votes4
answers3540
viewsA: How to count occurrences of a letter in a sentence?
Native method can be used String.prototype.split() to count the occurrence of one string in another. The method split([separator[, limit]]) divides a String in a array of Strings whose separator is…
-
1
votes2
answers101
viewsA: Doubt print game list of old Python
The first step to understanding your algorithm is to put it to work. For this I corrected some improper assignments and then rewrote comparison: if linha and coluna in positions: for: if all(p in…
-
4
votes2
answers83
viewsA: Function that creates list inside list
You can accomplish this task by using a list comprehension. The documentation thus defines: List comprehensions provides a concise way to create a list. Common applications are to create new lists…
-
7
votes3
answers171
viewsA: Does the function not return the minimum value?
As already said the problem is not in the function min_max() and yes in the way it gets its input. If the purpose of the program is for the user to enter a syntactically valid python list it is…
-
4
votes2
answers187
viewsA: How to check if the typed string is only '0' and '1'?
Even though the question is: How to check if the typed string is only '0' and '1'? Your code presents other problems and the most obvious is the over-processing to perform simple tasks that are…
-
1
votes2
answers54
viewsA: how to take duplicates from a list of dictionaries
Another possibility is to abandon the use of tuples, to tally medals, and in their place to use lists because tuples are immutable and not lists, which makes it easier to create a medal totaliser in…
pythonanswered Augusto Vasques 15,321 -
3
votes2
answers126
viewsA: How to create nested and counting dictionaries from lists/tuples?
The idea of the algorithm is to break the structured data passed in the list navio_fatiado in information subunits. For each item in the list navio_fatiado I imagine you as an object container which…
-
0
votes3
answers32
viewsA: Copy radio value to textarea
First thing you should do is get the reference of the elements that will work. Within the javascript to obtain the object reference html whose attributes ids are defined can be used…
-
0
votes1
answer94
viewsA: Dynamically save . html file with Javascript
Reply published by the questioner in the wrong place. for those who came for the solution: var textToSave1 = document.getElementById("código").value; var textToSaveAsBlob1 = new Blob([textToSave1],…
-
1
votes2
answers76
viewsA: Create fields dynamically in js
In summary the algorithm of your example says that: For every click of the button whose attribute id="add_field": Cancels the default event action. Make sure x is less than campos_max if it is…
-
3
votes2
answers67
viewsA: Shorten condition that checks if value is one of several possible
You can use the keyword in. Use keyword in, in a condition, to check whether a sequence(list, range, string) contains a certain value. Matches function contains(a, b) module Operator: a =…
-
0
votes2
answers104
viewsA: python vectors, help out?
Warning: the following program does not perform checks on the number of entries or perform any validation on them. The interpreter Python comes with built-in function filter(func, iteravel) that…
-
2
votes2
answers367
viewsA: Discover numeric sequence in javascript array
An alternative is to use a stack to store successive numbers. It works that way: For each element of the entrance look to the next neighbor: if the element is consecutive to Smash and look at the…
javascriptanswered Augusto Vasques 15,321 -
0
votes3
answers71
viewsA: Algebraic System - Python
Heed: This algorithm does no checking or error handling. linhas = int(input('Qual o número de equações no sistema: ')) a = [[0] * linhas for l in range(linhas)] #inicializa a lista de coeficientes.…
-
0
votes1
answer159
viewsA: options in html input
Use the attribute list of the element <input type="text"> together with the element <datalist>. The element <datalist> is an element container [<option>][2] that represent…
-
1
votes1
answer63
viewsA: Problem when trying to rotate a triangle using the javascript canvas
const canvas = document.getElementById('thecanvas'); let dpr = window.devicePixelRatio || 1; //Pega a proporção entre um pixel CSS e um pixel físico let rect =…
-
3
votes4
answers201
viewsA: How to reduce Python code 3?
As already mentioned in other answers this code does not bother to affirm the validity or not of the user input. n = int(input('Digite um número inteiro: ')) g = (n - n % 2 ) // 2 #Calcula a…
-
0
votes4
answers975
viewsA: Return a list from another list in Python
A simpler alternative would be to filter your list through the function built-in filter(funcao, iteravel) aided by a lambda expression. lista = [7, 9, 67, 44, 35, 14, 95, 7, 6, 78, 33] def maiores(…
pythonanswered Augusto Vasques 15,321 -
5
votes1
answer76
viewsA: Returning the inverse of a recursive sequence of numbers in Python
If you can make it simple. print('Digite uma lista de inteiros separados por espaço:') sequencia = [int(e) for e in input().split(" ")] sequencia.reverse() print(" ".join([str(e) for e in…