[Solved] why here Twice run program

Issues with Code : Object creation is not correct for password class. also argument self is not passed to class method . Fixed Code class password: def pas1(self): pas = [] tedad = int(input(‘how many do you have information ? : ‘)) for i in range(1,tedad): b=input(‘enter : ‘) pas.append(b) print(‘this is your pas —> … Read more

[Solved] Python3 Converting str with screened byte characters to str [closed]

[EDIT]The question was updated and the below was answered based on the original question. if you fix your input var1 then you can do something like this: var1 = ‘{“text”:”tool”,”pos”:”\\xd1\\x81\\xd1\\x83\\xd1\\x89\\xd0\\xb5\\xd1\\x81\\xd1\\x82\\xd0\\xb2\\xd0\\xb8\\xd1\\x82\\xd0\\xb5\\xd0\\xbb\\xd1\\x8c\\xd0\\xbd\\xd0\\xbe\\xd0\\xb5″}’ md = {} for e in var1[1:-1].split(‘,’): md[e.split(‘:’)[0][1:-1]] = e.split(‘:’)[1][1:-1] md[‘pos’] = (bytes.fromhex(”.join([h for h in md[‘pos’].split(‘\\x’)]))).decode(‘utf-8’) print(md) output: {‘text’: ‘tool’, ‘pos’: ‘существительное’} 2 solved … Read more

[Solved] Please explain the following inline python code? index = [n for n, value in enumerate(self.Variable[i]) if value == 1] [closed]

The above code can be rewritten as: indices = [] for n, value in enumerate(self.BUSES[i]): if value==1: indices.append(n) enumerate returns a pair of (index, value at that index) for a given list. So you are testing if value at a given index is 1, and if that is true, you add the index to indices. … Read more

[Solved] Converting Pseudo Code To Python [closed]

You should try to code something before posing on Stack Overflow. This will work but won’t catch any error conditions. options = [ {‘vehicle’: ‘Car’, ‘destination’: ‘Ghana’, ‘coeff’: 0.3}, {‘vehicle’: ‘Van’, ‘destination’: ‘Nigeria’, ‘coeff’: 0.2}, {‘vehicle’: ‘Truck’, ‘destination’: ‘Togo’, ‘coeff’: 0.33}, {‘vehicle’: ‘Van’, ‘destination’: ‘Kenya’, ‘coeff’: 0.17}, {‘vehicle’: ‘Truck’, ‘destination’: ‘Somalia’, ‘coeff’: 0.31}, ] while … Read more

[Solved] Decorator function [closed]

The question is not stated very clearly, but I would assume that those two functions are in some class. The problem is that you create a wrapper inside the class. Your wrapper check_if_logged expects two arguments self and function. When you use it as wrapper @ you give only one argument to the function check_if_logged … Read more

[Solved] How to split an integer into two integers that when multiplied they give the result of the first number [duplicate]

Every integer is divisible by itself and by 1. If the integer is composite, it will have at least one other pair of divisors (which may be the same, as in the case of 4, which is divisible by 1,4 and 2,2). lim = int(math.sqrt(num)) for i in range (1, lim): if num%i==0: print(i, int(num/i)) … Read more

[Solved] Could someone please go through this code line by line and explain it in Pseudocode or English

Some info on enumerate by typing help(enumerate) enumerate(iterable[, start]) -> iterator for index, value of iterable Return an enumerate object. iterable must be another object that supports iteration. The enumerate object yields pairs containing a count (from start, which defaults to zero) and a value yielded by the iterable argument. enumerate is useful for obtaining … Read more