Questions tagged as 'python-3.x'

3
answers

Avoiding code duplication without the use of switch / case in the Python language

Friends, I have the following code in Python: data_hoje = time.strftime("%d %b %Y", time.gmtime() ) #data de hoje data_desejada = time.strftime("%d %b %Y", time.gmtime(time.time() + (3600 * 24 * 2))) # daqui a 2 dias I know that in Pyth...
asked by 01.03.2017 / 04:26
3
answers

"break" does not end execution as it should

   Create a program where the user can type multiple numeric values and sign them into a list. If the number already exists inside, it will not be added. At the end, all the unique values entered will appear in ascending order. And so far so...
asked by 20.12.2018 / 18:42
1
answer

What is the Print Flush In Python? [closed]

I can not understand how the flush works in python's print.     
asked by 16.04.2018 / 23:07
3
answers

Floating-point problem Python 3

I'm writing an algorithm where I increment float variables in 0.2 , however, after a few increments instead of increasing 2.2 to 2.4 , for example, the program increments to 2.4000000000000004 I've read about this...
asked by 06.02.2018 / 23:48
3
answers

Replace list of words in a text

I always have a lot of trouble with replace and sub. I know how they work, but it never works for me. I have a list of words and I am trying to replace these words in a text: Text:    Brazil, officially the Federative Republic of Brazil...
asked by 17.07.2018 / 14:52
2
answers

Manipulating list of lists in Python

I have a list like this: Lista_A = [['de','do','da','ou'],['ae','ay','yhh','oo'],['ow','pa','la','for']] How do I leave it like this: Lista_A_new = ['de','do','da','ou','ae','ay','yhh','oo','ow','pa','la','for']     
asked by 08.10.2017 / 23:08
2
answers

Why does the list show the first two elements?

Declaring a list >>> convites = ['Flavio Almeida', 'Nico Steppat', 'Romulo Henrique'] When it shows, it appears like this >>> convites[0] 'Flavio Almeida' >>> convites[1] 'Nico Steppat' >>> convites[2]...
asked by 19.02.2016 / 11:26
4
answers

Debug showing variable name and value?

Many times when I need to debug the value of a variable at runtime I use print() . But when there are many variables, I need to identify the name of the variable along with the value. In this way print becomes more laborious : pri...
asked by 30.09.2018 / 16:27
3
answers

Instantiating a class in Python using an object as an argument

I'm starting to work with Python and I've seen that there's no way to create multiple con- trollers in the same class. With this I thought of passing to the% co_conductor an object containing the attributes of the class, as in the example: cla...
asked by 06.09.2016 / 16:51
2
answers

Read specific line of a txt file

I have a file of 1000 lines and I want to read line 952. I do not want to have to use a loop to go through all those lines, is there any more optimized way to do this?     
asked by 16.09.2018 / 20:40