[Solved] (Python) Replace array of string elements

you have to specify dtype to get the expected behavior, else it will choose minimum size, i think it is choosing chararray and you are trying add numbers/strings. either use astype or numpy.array(data, dtype=””) to set dtype, look at the syntax of numpy.arry below numpy.array(object, dtype=None, copy=True, order=”K”, subok=False, ndmin=0) set dtype to string/integer/float whatever … Read more

[Solved] Why isn’t length(self.next) a valid expression in python? [closed]

What is length? length does not exist, but Node.length does. The reason return(1+length(self.next)) doesn’t work is because you’re calling length(), not Node.length(). Instead, try this: return(1+LinkedList.length(self.next)) Or this (my preference): return(1+self.next.length()) solved Why isn’t length(self.next) a valid expression in python? [closed]

[Solved] Don’t understand this “NameError: name ‘self’ is not defined” error [closed]

From the exception it seems that you have tried to call my_wallet.checkBalance passing self as parameter. Try to do my_wallet.checkBalance() instead of my_wallet.checkBalance(self) self parameter is passed automatically to class methods in python 11 solved Don’t understand this “NameError: name ‘self’ is not defined” error [closed]

[Solved] what is arr = [int(arr_temp) for arr_temp in input().strip().split(‘ ‘)] in python

You may want to look into python’s list comprehension. arr = [int(arr_temp) for arr_temp in input().strip().split(‘ ‘)] Let me answer this with an example, suppose you input : 1 3 4 29 12 -2 0 the input function reads this as a string The strip function eliminates whitespace from both ends of the string, The … Read more

[Solved] No module named ‘PyPDF2._codecs’, even after already installed

This issue was only present in the PyPI distribution of PyPDF2==2.3.0 for a couple of hours. It was fixed with release 2.3.1. See #1011 for more details I’m the maintainer of PyPDF2. I’m sorry I caused some headaches. You can update PyPDF2 via: pip install PyPDF2 –upgrade solved No module named ‘PyPDF2._codecs’, even after already … Read more

[Solved] python re.compile match dosn’t match backward slash in full path in windows [duplicate]

So there are two things: The assignment of s should be either with escaped back-slashes or as a raw string. I prefer the latter: s = r”C:\x\xxx\temp\downloads\test_dir\sql\my-ee.sql” you should use the search method instead of match to be content with a partial match. Then, you can use \\\\ in the regular expression, or – as … Read more

[Solved] It only return one letter

You’re returning early in the loop, you need to build up a string and return that. Either just return a joint string or build it up “”.join(chr(ord(s)+4) for s in pas) def cip(pas): ret_val = “” for i in pas: asci = ord(i) encryption = asci + 4 ret_val += chr(encryption) return ret_val solved It … Read more