definition

How to returning a value that is not excluded in python?

How to returning a value that is not excluded in python? Question: I would like to create a function that would check if a given account is not a technical account. If the account is technical, we skip it, if not, we display account details. technical accounts are saved in the addc_accounts_excluded.json file: { "sAMAccountName": …

Total answers: 2

How to return data from one definition to another one?

How to return data from one definition to another one? Question: I am messing around with python, and am trying to make a simple data cleaning program. I’m trying to pass the title values from the read_excel module, to the output module. But, it keeps saying name title is not defined. Here is my code: …

Total answers: 3

What happens when I use [::-1] with a variable?

What happens when I use [::-1] with a variable? Question: So I have this code: t=int(input()) while t: s=int(input()) n=bin(s) n=n[2:][::-1] if n.count(‘1’)==1: pos=n.find(‘1’)+1 print(pos) else: print(‘-1′) t-=1 I would like to know exactly what’s going on in this line: n=n[2:][::-1] What does [::-1] means? Asked By: jafemm || Source Answers: It takes the reverse …

Total answers: 1

Python – instance attribute defined outside __init__()

Python – instance attribute defined outside __init__() Question: I get the warning in question for the following code: from tkinter import * from tkinter import ttk class Autocomplete(Frame, object): def __init__(self, *args, **kwargs): super(Autocomplete, self).__init__(*args, **kwargs) self.list = [] def build(self, width, height, entries): # I get the warning for the following 8 lines: self._entries …

Total answers: 2

Function Definition: Matching Area Codes to Phone Numbers

Function Definition: Matching Area Codes to Phone Numbers Question: If I want to define a function called match_numbers, which would match the area code from one list to the phone number of another list, how should I fix my code? For example: match_phone([‘666’, ‘332’], [‘(443)241-1254’, ‘(666)313-2534’, ‘(332)123-3332’]) would give me (666)313-2534 (332)123-3332 My code is: …

Total answers: 5

Difference between list, sequence and slice in Python?

Difference between list, sequence and slice in Python? Question: What are the differences between these built-in Python data types: list, sequence and slice? As I see it, all three essentially represent what C++ and Java call array. Asked By: Tony the Pony || Source Answers: lists are a sequence type, similar to an array sequence …

Total answers: 5