Posts by Vitor Guimarães • 367 points
15 posts
-
0
votes1
answer85
viewsA: Python dictionary
The problem is the identation of return(contagem). You put him inside the for, then the loop only happens once and the function returns. Indent the indentation of this line that the problem will be…
-
4
votes1
answer58
viewsQ: What is the "-->" operator in C?
I’ve never seen this operator before, just another like ->, but it makes no sense in the context of that code. Code #include <stdio.h> int main() { int x = 10; while (x --> 0) { // x…
casked Vitor Guimarães 367 -
2
votes1
answer136
viewsQ: How do closures work on Swift?
Perhaps this is one of the most difficult concepts to understand for those who are beginning in language. I’ve seen some definitions but so far I can’t understand. Could someone give an explanation…
-
1
votes2
answers78
viewsA: Access vector value by index
In the ASCII table the char characters have a Decimal, Hexadecimal, Octal and char. Let’s just focus on the decimal representations and char. According to the table, v is equivalent to 118 in…
-
2
votes1
answer44
viewsA: Modifying privileges with python
After doing the operation you need privileges, enter this code: sudo_uid = int(os.getenv("SUDO_UID")) sudo_gid = int(os.getenv("SUDO_GID")) # drop root privileges os.setresgid(sudo_gid, sudo_gid,…
-
2
votes1
answer32
viewsA: Can I convert the output of an object using get()?
Use the function float(). It’ll stay that way: command = Sistema_backend.Sistema(float(Entry1.get()), float(Entry2.get()), float(Entry3.get()), float(Entry4.get()), float(Entry5.get())) If no…
-
0
votes1
answer305
viewsA: pygame installation error in vs code
The problem is more likely with python 3.8, you need to compile it or use an older version of python (<= 3.7).
-
1
votes2
answers56
viewsA: I can’t find the highest value in a flip-book dictionary
There are some problems with your code, but it is very simple to solve. I will try to explain well. First let’s look at the form of the dictionary you created. a = dict() a['A'] = sample(range(0,…
-
1
votes2
answers503
viewsA: How to make python3 recognize the emoji module?
You must be using python 2 as the default system, so when you use Pip it installs the python 2 package. Try it like this: pip3 install emoji
-
0
votes2
answers39
viewsA: Remove list duplicity with Python
I did a job but simple to understand. It receives by parameter your list and the indexes you want to compare, which in this case is the first and the second. The function deletes duplicate data…
pythonanswered Vitor Guimarães 367 -
0
votes2
answers48
viewsA: I’m trying to make a show that gets an n number and returns all the cousins up to n, but I don’t know what’s going wrong
Your code does not return the right answer. If you haven’t yet, I suggest you test this code: def primo(numero): div = 0 for n in range(1, numero+1): if numero % n == 0: div += 1 return div numero =…
pythonanswered Vitor Guimarães 367 -
1
votes3
answers1081
viewsA: error install virtualenv in python
Let’s start by installing the Pip. In your terminal enter: wget https://bootstrap.pypa.io/get-pip.py sudo python3 get-pip.py With Pip installed, we will install virtualenv and virtualwrapper: sudo…
-
1
votes1
answer32
viewsA: Error 'Attributeerror' in python
You are using get_text() and .text functions. I Removed get_text() from your code and used get("title") in your loop, so it Works! Please, Try this code: from bs4 import BeautifulSoup as bs from…
pythonanswered Vitor Guimarães 367 -
1
votes3
answers1779
viewsA: How not to repeat values in a Python list?
If you need to keep order, access list indexes and you are dealing with lists in your project, you are not required to use set(). There is a simple solution using dict.fromkeys() to remove the…
-
1
votes2
answers52
viewsA: I’m not finding the highest value in a list with random values
You get this error because you are adding brackets to your sample, but the sample function already returns a list. Random.sample(Population, k) Return a k length list of Unique Elements Chosen from…