Posts by Guilherme França de Oliveira • 454 points
14 posts
-
6
votes3
answers329
viewsA: Why does my "Try" in Python not work?
The try serves exactly for this, to launch an exception of yours without necessarily stopping the program, however, the way you are trying to use this incorrect, the line that throws the exception…
-
0
votes1
answer58
viewsA: Problem to find the lowest value
I think I understand your problem he is present in that part if tot < menor: menor = tot he checks whether the total is less than menor whereas the menor is equal to 0, then in fact he will never…
pythonanswered Guilherme França de Oliveira 454 -
3
votes6
answers19845
viewsA: How to change the name of the pandas dataframe column?
Try it like this import pandas as pd df = pd.read_csv('dados.csv', sep=';', names=['nome_completo', 'idade'], header=0) depending on your csv file, you may need to assign header=1 to omit the…
-
1
votes2
answers175
viewsA: Import into different directories in Python3
I believe you already know the 'import', however, for larger ways you use the from I’ll give a few examples to be clear remembering that it also depends on the env if using but an example according…
python-3.xanswered Guilherme França de Oliveira 454 -
1
votes2
answers57
viewsA: Input resulting in None
this happens by the fact of its function print_slow() returns the value None, simple as that. and the input() also shows a value on the screen, next to the value that print_slow returns which is…
pythonanswered Guilherme França de Oliveira 454 -
5
votes1
answer112
viewsA: How to imitate "until... you do" command with python?
You can use the for for this, I will put an example below. for count in range(10, -1, -1): print("Eu conto", count) is quite simple in addition you can add the team, I will give an example below…
-
0
votes2
answers123
viewsA: How to find a string in a python txt
Your code is very broken, you won’t get much with it, I advise you to try to rewrite it, but if you want the result using the same or even see how you could do so that your right code made some…
-
3
votes1
answer170
viewsA: Return returns only the first value of the list (python)
there are many things I advise you to change in your code, let’s go to your first problem. for title in page_soup.select('li.node-readmore > a'): t1 = title.get('title') return t1 this way you…
pythonanswered Guilherme França de Oliveira 454 -
1
votes2
answers440
viewsA: How to do a subtraction operation between two columns of a dataframe and then add the result with another column?
When you use the pop it deletes the value of the variable, then the second time you actually use it there is no value in it you can do so y = (dados_train['col_name1'] - dados_train['col_name2']) +…
pythonanswered Guilherme França de Oliveira 454 -
0
votes2
answers672
viewsA: Edit a file name using Python
following your code I made this small modification from pathlib import Path import os path = Path('diretorio') try: for _ in path.glob('*.pdf'): new_name = os.path.basename(os.path.dirname(_))…
pythonanswered Guilherme França de Oliveira 454 -
1
votes1
answer111
viewsA: Program to check number of words and a sentence of a text file
In your code you are collecting the sentence up to a specific punctuation and checking how many words there are in it, in case your file where the word is Prophet! this a little earlier Quoth the…
-
2
votes3
answers81
viewsA: Why does this account return a negative number?
The reason is simpler that it seems, there is nothing wrong in the account, it actually multiplies first having the value of 6, however, then becomes like 1 - 6 which is equal to -5 I have 100 real…
javascriptanswered Guilherme França de Oliveira 454 -
3
votes1
answer97
viewsA: How to make a list of recursive iterations - Python
you do not want to repeat the numbers but show all the interactions at the end? it changes the values of the other list by account that are referenced, to end this problem just use the slice…
-
0
votes3
answers450
viewsA: Rename files and move out of the Python directory
The mistakes you’re having may be for some reason that we won’t be able to test, but you should use error treatments to prevent them Follow a small modification I already performed by renaming and…
pythonanswered Guilherme França de Oliveira 454