Questions tagged as 'python'

3
answers

Problems with the Python indentation in Geany

Since I changed IDE (I moved from Pycharm to Geany), I started to have many problems with the error: "inconsistent use of tabs and spaces in indentation". I would like to know a way to solve this constant problem, use only tab for indentation...
asked by 25.09.2017 / 21:03
1
answer

File path with error to execute mp3

I was solving a proposed exercise in a course that was to execute an mp3 file passing the same path, I researched a little and I got to this code: from playsound import playsound playsound('C:\Downloads\c.mp3') When I ran it gave error:...
asked by 01.08.2017 / 07:18
1
answer

Web Scraping - convert HTML table into python dict

I'm trying to turn an HTML table into dict @ python, I came across some problems and I ask for help from you. Follow it as far as I could get ... def impl12(url='http://www.geonames.org/countries/', tmout=2): import requests from bs...
asked by 01.08.2017 / 16:59
1
answer

Accentuation error when saving file in Python

I'm not able to save a file with accentuation in python, I've come to ask for a help from you; import csv f = open('output.txt', 'w') data = [] def parse(filename): with open(filename, 'r') as csvfile: dialect = csv.Sniffer(...
asked by 11.04.2017 / 01:23
1
answer

a bug in the range () function?

I've been writing a function for a class that takes a dictionary and converts it to a string to represent an array. def __str__(self): grid_str = ['' for _ in range(self.heigth)] for y in range(self.heigth): for x in range(s...
asked by 25.01.2017 / 12:47
1
answer

Porting Java code to C ++ or Python [closed]

I'm working on a project that was originally written in Java. I want to learn more about math and logic behind the code, and I had the idea of porting the code to another language. I thought of C ++ and Python. Which one has more simila...
asked by 31.08.2016 / 21:58
1
answer

How to print all the vowels present in string?

I am learning now to program, and I chose Python, and I am not being able to solve this school exercise. The code I have is: nome = input("Digite o nome: ") b = nome.find("a") This code finds 15 to nome equal to "one two three...
asked by 26.04.2017 / 23:54
2
answers

How do I delete a file from a folder in python

The code below lists the files of a certain directory, I wanted to know how do I delete only 1 file from this directory def etc(): path ="diretorio"' dir = os.listdir(path) for file in dirs: print(file)     
asked by 28.04.2017 / 04:01
3
answers

Python "list out of the range"

I'm trying to put two columns of data, each one in a different file with the names you'll see in the code, in a single file as two columns side by side. The error, quoted in the title ("list out of the range") always appears where I will indicat...
asked by 17.03.2017 / 02:27
2
answers

Transform cycle in function of higher order

Good afternoon, I have this function containing a cycle: def ciclo(x,y): lista = [] for i in x: if i[0]==y: lista.append(i[3]) return sorted(lista) And I wanted to turn it into a line of code, using the pytho...
asked by 19.04.2016 / 16:59