[Solved] Why am I receiving this Template error in my django tutorial?

[ad_1] You are making a type mistake while sending the template name in detail view. return render(request, ‘polls/detail.html’, {‘question’:question}) You have set the template name as ‘polls/detail.html’ but your template is details.html in your file. Rename the template file to detail.html and it will work fine. 0 [ad_2] solved Why am I receiving this Template … Read more

[Solved] Any built-in function in pandas/python which converts a list like data into a list

[ad_1] Yes, there is the split function, however before calling it on your string, you must get rid of the [ and ], or else instead of [‘1’, ‘2’, ‘3’, ‘4’], you will get [‘[1’, ‘2’, ‘3’, ‘4]’], so instead of s.split(), we do s[1:-1].split(), also this means your list is strings instead of ints … Read more

[Solved] python code to create a merged file

[ad_1] Assuming you can read the data from file and hold it into two string say input1 and input2 below code should do what you are looking for word_list_1 = input1.split(” “) for str in input2.split(“\n”): word_list_2 = str.split(” “) for word in word_list_1: if word in word_list_2: sys.stdout.write(“1”) else: sys.stdout.write(“0”) sys.stdout.write(“”) sys.stdout.write(“\n”) [ad_2] solved … Read more

[Solved] “name ‘self’ is not defined”

[ad_1] You need to first install the package with the command : pip3 install numpy on your shell (I assume you use Python 3). After you need to write on the top your code : import numpy EDIT : With a quick search on Google, I found this : class neuralNetwork: # initialise the neural … Read more

[Solved] I want to write a function that takes 2 strings and returns True if they are anagrams(any word that have the same letters in different order) [duplicate]

[ad_1] I want to write a function that takes 2 strings and returns True if they are anagrams(any word that have the same letters in different order) [duplicate] [ad_2] solved I want to write a function that takes 2 strings and returns True if they are anagrams(any word that have the same letters in different … Read more

[Solved] Cache._cache.flush_all () not working, How can I clear the cache with django and memcached?

[ad_1] From Django documentation for cache Finally, if you want to delete all the keys in the cache, use cache.clear(). Be careful with this; clear() will remove everything from the cache, not just the keys set by your application. You can also flush content of memcached by connecting by telnet or nc and executing flush_all … Read more

[Solved] Can someone point out the errors in this code? [closed]

[ad_1] You didn’t provide parameters for cal_volume() and display() in your def main(). It should be: import math def main(): radius = get_radius() calculate = cal_volume(radius) dis = display(calculate) # print out the result? def get_radius(): rad = float(input(“Enter the radius :”)) return rad def cal_volume(radius): return 4/3*math.pi*radius**3 def display(cal_volume): print(“The volume is :”,cal_volume) main() … Read more

[Solved] Data structures homework in Python

[ad_1] This should work well, just needed to correct some things. def manipulate_data(data): if isinstance(data, list): return [sum(1 for n in data if isinstance(n, int) and n >= 0), sum(n for n in data if isinstance(n, int) and n < 0)] else: return ‘Only lists allowed’ [ad_2] solved Data structures homework in Python

[Solved] Python copy to new list and exclude items

[ad_1] b = [item for x in a for item in x if x.index(item) in [0,3]] let a be your main list. this returns item in position 0,3. moreover you can add any other index to that list if you want. [ad_2] solved Python copy to new list and exclude items