Posts by Henrique Hott • 317 points
11 posts
-
0
votes1
answer96
viewsA: Identify repeated strings in a list
What I advise is that before you use the method append(), first check if the theme is already in the list with the operator in, returning True if so, and False, if you’re not. As the condition to…
pythonanswered Henrique Hott 317 -
1
votes2
answers52
viewsA: I can’t write a specific number count inside a list
To simplify the explanation I will generate the same problem in a smaller code. #MESMO PROBLEMA EM UM CÓDIGO MENOR numeros = list() for i in range(5): num = input('Digite um número: ')…
python-3.xanswered Henrique Hott 317 -
2
votes1
answer43
viewsA: Loop error with for loop and loop control variable
What’s missing are the keys to the loop for. #include <stdio.h> void main(){ for(int i = 0; i >= 1; i--){ printf("%d garrafas de cerveja no muro\n", i); printf("bebo uma jogo no lixo\n");…
functional-programminganswered Henrique Hott 317 -
1
votes1
answer349
viewsA: How to change values of only one column in an array (PURE Python)
What you can do is work with dictionary, because of key system: value. It works well for several reasons, for example, the code is easier to read, as it does not have several if and elif. Basically…
pythonanswered Henrique Hott 317 -
-2
votes2
answers114
viewsQ: Most efficient algorithm to find indices of the 2 elements of a list whose sum is equal to a certain value
The Challenge is simple, find two numbers from a given list that if summed result in a specific number and return the index of those numbers. That I solved, the problem is that in addition the…
-
-2
votes2
answers119
viewsA: Search an array (list list)
Just to illustrate, I took the same matrix and separated only the names of each profile, apparently, I didn’t know either, but when you open the second bracket to access the element of the matrix…
-
0
votes1
answer67
viewsA: Can anyone help me find the bug? python!
Some errors in your code: while not -1: creating an infinite loop. The user could indicate a different number of notes than the amount he was going to pass. Didn’t calculate the average using all…
-
2
votes1
answer55
viewsQ: Read file with list comprehension only works the first time
fhand = open('text.txt', mode = 'r') txtfile = [item.split()[0] for item in fhand] txtfile2 = [item.split()[1] for item in fhand] print(txtfile) print(txtfile2) Why the second comprehensilist on is…
-
0
votes1
answer43
viewsQ: Doubt about while loop on C?
I need to know why 0 has to be typed twice in order for the program to stop traversing the loop. And the same thing happens when I use the do-while. #include <stdio.h> #include…
-
5
votes2
answers238
viewsQ: Python dictionary and functions
I don’t understand why the following code says that it is receiving more than one pro value same parameter. def foo(name, **kwds): return 'name' in kwds foo(1, **{'name' : 2})´ Typeerror: foo() got…
-
0
votes1
answer39
viewsQ: Result - . find() - Different from expected
When I spin that code: fname = input('File name: ') fhand = open(fname) count = 0 for line in fhand: if line.find('Subject:'): count = count + 1 print('There were', count, 'subjects lines in ',…
pythonasked Henrique Hott 317