I have the following code:
list1 = ['a', 'x', 'c', 'b', 'm']
list2 = ['f', 'x', 'a', 'c']
list3 = ['c', 'e', 'x', 'b', 'p', 'k', 'l']
How do I find the common elements, so that I get a list like this:
comuns = ['x', 'c']
I'm a beginner in python and needed to do a program that checks if a given word is palindromous. The program would then be:
#encoding: utf-8
palavra = input ('Palavra: ')
if palavra == palavra[::-1]:
print ("%s é palindrome" %palavra)
else...
I have the following list
my_list = [1,2,3,4,5,6,7,8,9]
Let's say I want to remove num 7, by value and / or key, and stick with:
my_list = [1,2,3,4,5,6,8,9]
How do I do it?
I'm working on a project with multiple apps. The department app model is as follows:
from emails.models import GerenciarEmails
class Departamento(models.Model):
#modelo de grupos de disciplinas
class Meta:
verbose_name = 'Departamento'...
I'm developing a small application in Pyqt4 where I need to load the data into a table coming from a Webservice. This I was able to do quietly. But now, I need to update this every 1 minute.
How can I do a repetition of a call to a function e...
How do I read a file or Yaml code with Python?
Is it necessary to install anything, or can you do it natively?
Example:
fruits:
- Apple
- Orange
- Strawberry
- Mango
I have a dictionary with the following format
dic={759147': 54, '186398060': 8, '199846203': 42, '191725321': 10, '158947719': 4}
I'd like to know if there's any way to sort it by value and print it on the screen. So the output is.
'15894...
arq=open('filmes.txt','r')
filmes = arq.readlines()
def buscaPorGenero():
genero=str(input("Digite o gênero do filme: "))
while(True):
for linha in filmes:
linha = linha.split(";")
if genero in str(linha[1]):
prin...
In PHP, when I want to get a remote content (some url, for example), I use the proper functions to open files and this works perfectly.
Example:
file_get_contents('http://pt.stackoverflow.com/')
And in Python, what is the correct way to...
What is the best way to do Python expositoning?
Should I use the ** or math.pow ?
Example math.pow :
> math.pow(3, 4);
#Imprime: 81.0
Example with double asterisks ?
> 3 ** 4
#Imprime : 81
What should I...