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

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 solved Why am I receiving this Template error in … Read more

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

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 (‘1’ … Read more

[Solved] python code to create a merged file

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”) solved python code … Read more

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

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 network: … 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]

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] 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]

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

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 echo … Read more

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

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() 1 … Read more

[Solved] Data structures homework in Python

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’ solved Data structures homework in Python

[Solved] Python copy to new list and exclude items

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. solved Python copy to new list and exclude items