Questions tagged as 'python-3.x'

1
answer

What is illegible for python?

I would like to know what exactly is wrong with this python code: import urllib.request page = urllib.request.urlopen("http://beans-r-us.appspot.com/prices-loyalty.html") text = page.read().decode('utf8') price = 99.99 while price > 4....
asked by 19.11.2016 / 14:45
2
answers

How do I change the 3rd and 5th occurrence of a word in a string

Someone can help me in this, I need to change the 3 and 5 occurrence of a word in a text, I can not change the other occurrences. Texto=input("Digite o Texto: ") #recebendo o texto do usuario Palavra=input("Digite a Palavra: ")#Recebendo a pa...
asked by 14.08.2016 / 19:11
2
answers

Python how to print output

How can I print a list in this way, for example: l=[4,26,32] I want to print the output as follows: 4 26 32 No comma and with a blank space on the same line. Thank you in advance.     
asked by 24.02.2016 / 02:29
1
answer

Dynamic typing and team development

There is some good practice, standardization, recommendation, etc. that aims to prevent invalid types from being passed to methods and functions? If I'm working alone, it's calmer, I wrote the method myself so I know what kind of parameters i...
asked by 07.06.2018 / 21:20
2
answers

What function do I use to return or show all equal numbers in a list of 20 numbers?

n = [] for i in range(20): n.append(int(input("Digite o número: ")))     
asked by 15.05.2017 / 02:40
1
answer

How to tokenize words in Portuguese using NLTK?

I'm having a hard time understanding this mechanism. In English it would just be: import nltk tag_word = nltk.word_tokenize(text) Being text is the English text that I would like " tokenizar ", which happens very well, but in Port...
asked by 21.07.2017 / 00:40
1
answer

Regex custom time in python 3

I need to create a regex that accepts the following entries: 8:00 8 horas 8h 8h30 (8h 30) 8h30min (8h 30 min) 8h30minutos (8h 30 minutos) And I came up with the following: ((\d{1,2}:\d{1,2}) | (\d{1,2}\s+\bhoras\b) | (\d{1,2}...
asked by 18.08.2017 / 15:24
1
answer

How to check the latest file in a folder with Python?

Assuming you have a folder with several TXT files with different names and need to know the latest file, how do I do this using Python?     
asked by 20.04.2018 / 14:13
1
answer

Determine the key of a dictionary that contains the largest amount of values

animals = { 'a': ['aardvark'], 'b': ['baboon'], 'c': ['coati']} animals['d'] = ['donkey'] animals['d'].append('dog') animals['d'].append('dingo') Be the animals dictionary defined above. The function applied to it should return the key...
asked by 22.04.2018 / 01:48
1
answer

How to get a string with the name of the window that is focused on python?

Some time ago I started using pyHook to handle events. However, the original version has errors, so I changed it to an alternate version that corrected the errors of the original version. However, I have found that this alternate version always...
asked by 11.02.2017 / 21:57