Questions tagged as 'python'

1
answer

How do I avoid calling the same function multiple times?

I have two script files, one for accessing a CSV file, turning each line into a dictionary, and returning a list of dictionaries (lines). My second script is a function to create a new column in the file (C1), copy the data from another colum...
asked by 28.11.2017 / 03:57
1
answer

Location of a character in python

I adapted a program in Python that solves labyrinths, and I am improving it, but I had problems with the minimum path (I even studied it in Graphs), I was able to understand everything. But I have trouble finding the position (x, y) of the targe...
asked by 25.02.2018 / 13:19
1
answer

Web Crawler searching for specific text on the page

Well, I'm doing a web crawler to fetch the value of a coin. I wrote the following code in python: #coding: utf-8 from urllib2 import urlopen conteudo = urlopen('http://dolarhoje.com/bitcoin').read() procurar1 = '<span class="symbol"&g...
asked by 03.11.2017 / 20:43
1
answer

Python - invalid literal for float ()

I have an array that looks like this training_set = [['03/11/2017' '16,94'] ['01/11/2017' '16,90'] ['31/10/2017' '16,77'] ... However, I can not manipulate the numbers because they are in the form of string . How do I clean the data and...
asked by 07.11.2017 / 02:17
1
answer

Return in a DataFrame - Python

Good afternoon. I have a question regarding Python. I have an if where has the conditional and else, the else it processes more than one file and I need to save all the information it reads inside a DataFrame, is there a way to do this? The c...
asked by 22.05.2018 / 20:43
1
answer

How to import packages into other sub packages in Python?

I have the following structure in a project PacoteRaiz/ __init__.py Pacote1/ __init__.py Modulo1.py Pacote2/ __init__.py Modulo2.py If I want to, for example, use some function that is insid...
asked by 20.05.2018 / 21:36
1
answer

RuntimeError: maximum number of recursive calls exceeded - python

fibonacci_cache = {} def fibonacci(n): if n in fibonacci_cache: return fibonacci_cache[n] if n==1: value=1 elif n==2: value=1 elif n>2: value=fibonacci(n-1) + fibonacci(n-2) fibonacci_cache[n]=...
asked by 07.11.2017 / 19:51
1
answer

OMDb API ordering items python dictionary

I need to make a program that given a given name, return the movie name and the year it was released using the api OMDb, and sort by the release year. I managed to list the movies but I can not sort by the year of release, because it is a dictio...
asked by 15.11.2018 / 22:35
2
answers

ASCII in Python

Hello. I come from C and I'm starting to learn Python. I have a question to move the characters of a string 3 positions and in C would look something like this: str[i] += 3; I tried to do the same thing in Python and it ended up causing an...
asked by 03.02.2018 / 19:47
1
answer

How to ignore certain elements in a list that will undergo a random process? (pending)

This program finds magic squares 3x3 by brute force and automatically prints when you find one. code: import random vetor = [1, 2, 3, 4, 5, 6, 7, 8, 9] def magicsquare(): return vetor[0]+vetor[1]+vetor[2]==\ vetor[3]+vetor[...
asked by 28.12.2017 / 23:38