No one has voted on any posts yet. Votes from other community members are used to determine a member's reputation amongst their peers.
11 Posted Topics
hi ppl, Consider a list like ['a.1','b.3','b.4','c.2']. Here 'a','b','c' are objects and 1,3,4,2 are their instance ids and they are unique e.g. a.1 and b.1 cannot exist together. From this list i want to generate multiple lists such that each list must have one and only one instance of every … | |
Re: I am facing a similar problem,i want to round off my bumbers till 2 digits after decimal points.e.g 4/6 to 0.66,3/5 to 0.80,etc for variables prList and count,i tried >>>round(len(prList)*1.0 / count,2) This gives me long results like 0.67000000000000004 Even though i'm specifying the number 2. | |
I want to generate all substrings of size k-1 from a string of size k. e.g 'abcd' should give me ['abc','abd','bcd','acd'] Order of these strings in the list doesnt matter. Also order doesnt matter inside the string e.g 'abc' or 'bca' or 'bac' is the same. The following code doesnt … | |
I have a list of strings all of length k. For every pair of k length strings which have k-1 characters in common, i want to generate a k+1 length string(the k-1 common characters + 2 not common characters). e.g i want to join 'abcd' with bcde' to get 'abcde' … | |
I wrote the following code to concatenate every 2 keys of a dictionary and their corresponding values. e.g if i have tiDict1 = tiDict1 = {'a':[1,2],'b':[3,4,5]} i should get tiDict2={'ab':[1,2][3,4,5]} and similarly for dicts with larger no. of features. Now i want to check each pair to see if they … | |
I want to generate all size 2 strings from a list of size 1 string e.g featureList = ['a','b','c','d'] gives ['ab','ac' etc] I wrote this code [code] def genC(featureList): for i in range(0,len(featureList) - 1,1): for k in range(1,len(featureList) - 1,1): if i+k <= len(featureList)-1: colocn = featureList[i] + featureList[i+k] … | |
I want to generate 'substrings' from a string as follows: for each substring j of string,generate the 2 lists [j,string - j] and [string -j,j] e.g If i have a string 'abc' i want to generate the list [['a','bc'],['bc','a'],['c':'ab'],['ab','c'],['b':ac],['ac':b]] Now i tried the following but its not giving me the … | |
I need to map one list onto another.l1 is a list of lists of lists and l2 is a list of numbers.I want elements of l1 to be the keys and elements of l2 as the values.I tried to convert l1 into a tuple and then mapping but it doesnt … | |
When i tried the following in python interpreter,i got a syntax error: [code] d = {[[['a': 1,'b': 2],['a': 4,'b': 3]][['a': 2,'c': 2],['a': 1,'c': 3]]] : 0.4} [/code] Pleeeez help :sad: | |
If i have a list (or list of lists) with elements of size k and i want to generate all higher level elements (of size k + 1) from it,what should i do??Any pointers would be of a great help I tried the following for lists...for list of lists i … | |
this doesnt work when the file is in the same directory as the .py file. [code] def get_colocations(filename): sentences = open(filename).read().split("\n") colocations = [] for sent in sentences: colocations.append(sent) return colocations def main(): get_colocations("colocations.txt") print "Colocations are",colocations [/code] Can anyone help???????? |
The End.