Posts by GlaucioFonseca • 317 points
13 posts
- 
		2 votes1 answer42 viewsQ: Seek word with accuracyGood staff I have a small text of 1859 words where I have stored it all in a variable string format. The question and the next I have this little code I made below: w = wordstring.split() i = 0 for… python-3.xasked GlaucioFonseca 317
- 
		1 votes1 answer91 viewsQ: Doubt def function with tuple mode inputGood person I have the following code: def tuplas(x): return x[::2] tuplas(('Hello', 'World', 'estamos', 'vivos')) This code will work perfectly, but if I remove the parentheses of my tuple,… 
- 
		0 votes1 answer85 viewsQ: Doubt while loopI have the following code: # -*- coding: utf-8 -*- def soma(lista): soma_num = 0 while soma_num <= lista: soma_num += a return soma() a = [1, 2, 3, 4] print(soma(a)) I know it will give error on… 
- 
		1 votes1 answer234 viewsQ: File output accentuation problem saved on equipmentGood guys I have the following file saved in my equipment "names.txt", this one containing 1190 lines. Follow my python2.7 code: #/usr/bin/python env # -*- coding: UTF-8 -*- abrir =… 
- 
		0 votes3 answers25438 viewsA: How to run programs written in Python in windows by hiding terminal feedbackHave you tried renaming your file .py for .pyw? This causes the program to run in the background with no return from the terminal. 
- 
		1 votes1 answer3392 viewsQ: Adding character to a stringGood person my doubt and the next, I have the following situation: i have the following variable >>> a = "EXAMPLE" Let’s assume I had to remove the letter "M" right string, in this case I… 
- 
		5 votes1 answer995 viewsQ: Adding a comma to a stringGood personal and possible to add comma in an example string: a = '1234567890abcdefghijklmnopqrstuvwxyz_' for her to stay like this a = 1,2,3,4,5,6,7....… 
- 
		1 votes3 answers8338 viewsA: What does %=mean?There is also the divmod function, which returns the result of the division and the rest of it. >>> divmod(3, 2) (1, 1) >>> 
- 
		2 votes1 answer55 viewsQ: Problem Returning sh: 0: -c requires an argumentGood guys next, I have this code below for python 2.7: #!/usr/bin/env python # -*- encoding: utf-8 -*- import sys import os if len(sys.argv) <= 3: for comando in sys.argv[1:]: shell =… python-2.7asked GlaucioFonseca 317
- 
		1 votes4 answers14598 viewsA: Print only the column of a matrixSave Andre you want something like this: >>> matriz = [[1, 5], ... [7, 4], ... [8, 3]] >>> for m in matriz: ... print m[1] ... 5 4 3 >>> If you want the first column just… pythonanswered GlaucioFonseca 317
- 
		4 votes1 answer567 viewsQ: How to convert this code from Python version 2 to 3.4?I’m having a hard time convert the code below for the version 3.4 of Python, the purpose of this code is to encode and decode hexadecimal, in order to create shellcodes. import binascii, sys, time… 
- 
		2 votes3 answers1630 viewsA: Problem with randint functionSave friend, follow random numbers code without repetitions. I hope it helps you import random lista = [] while len(lista) < 4: x = random.randint(1, 50) if x not in lista: lista.append(x)… 
- 
		-4 votes4 answers7094 viewsA: Swap the first character of a string with the last python characterThere is another way too, suddenly can help you but the difference and he writes backwards the word. >>> def troca(s): return s[::-1] >>> troca("bar") 'rab' >>>…