Questions tagged as 'python-3.x'

1
answer

How to return data from a select in sqlite3 as dictionaries instead of tuples in Python?

I'm using sqlite3 to write some data. However, by default, when a select is made, it returns the information as a list of tuples, which is considerably more difficult to work than if they were dictionaries. Example: >>> import sqlite3...
asked by 28.10.2016 / 13:16
1
answer

What is the best method to perform a menu with submenus (while with breaks or calling menus in functions)? [closed]

For a school job, you need to have a menu with several submenus. What is the best way to approach this? I can put the menus inside whiles and go giving break to those whiles when you want to go back to the previous one or separate the...
asked by 21.12.2016 / 14:54
1
answer

Porting a Python 2 code to Python 3: Error ICMP Scan

I have the following code: import random import socket import time import ipaddress import struct from threading import Thread def checksum(source_string): sum = 0 count_to = (len(source_string) / 2) * 2 count = 0 while coun...
asked by 31.08.2016 / 23:27
1
answer

How to create a UDP port scanner in python 3?

My code is always giving "port is opened". My idea is: if the destination responds, the door is open. Otherwise, it may be filtered ... ##################################### # Portscan UDP # # # ##################################### # -...
asked by 18.08.2016 / 17:08
1
answer

Import error when sending simple email with python

I am learning to send email in python and am encountering several problems. One of them is already in importing the smtplib module. My code is as follows: from smtplib import SMTP smtp=SMTP('smtp.live.com',587) smtp.starttls() smtp.login('my@h...
asked by 29.12.2016 / 15:42
1
answer

Problems executing commands in CMD with Python

I am not able to execute (or get the result) of commands executed in Windows by Python. I got a code sample I saw on various sites and answers in the OS, but none worked well for me. import subprocess # Exception: [WinError 2] The system cann...
asked by 25.08.2016 / 23:09
1
answer

Conversion of response into lists

I have a small problem in my algorithm, I have to receive an "institution name" any user entered and convert it into a list for future use in other conditions, but this is by converting all the letters of the name to the string and putting it on...
asked by 21.05.2016 / 08:47
1
answer

Dictionaries receiving list with values

I have a little problem with my code, it receives "institutions" (names that the user wants in the input) within a dictionary, this input is passing the dictionary as a list, and then I use the list to make a "donation "until then it is quiet th...
asked by 22.05.2016 / 23:16
2
answers

Add elements to a list within a list comprehension

I have following code: myList = [1,2,3,4,5] result = [] test = [result.append(i) for i in myList] Whose output of test is:    [None, None, None, None, None] I would like to know why, since for example: test = [print(i) for i...
asked by 25.05.2016 / 19:51
2
answers

Ackerman function - Python

Well, I'm still learning to program in python and I came across exercise that I do not know how to solve. I need to write a function that solves Ackermann's famous function. I think I will not have problems with the syntax and logic behind th...
asked by 14.10.2015 / 00:23