[Solved] Given a 6 blocks, of different height h1, h2 . Make 2 towers using 3 Blocks for each tower in desired height h1, h2

elemnts=[2,2,0,0,5,6] h1=9 h2=6 def func(elemts,a,b): list1=[] for i in range(0,len(elemts)): for j in range(i+1,len(elemts)): for k in range(0,len(elemts)): if(k not in [i,j]): temp=elemts[i]+elemts[j]+elemts[k] if(temp in [h1,h2]): list1.extend([elemts[i],elemts[j],elemts[k]]) return list1 list2=func(elemnts,h1,h2) @arthur_currry…just chnged one line in last if case.Its working fine solved Given a 6 blocks, of different height h1, h2 . Make 2 towers using … Read more

[Solved] Average Innings Score in python

The way you are taking input is wrong When you do this s[i][j]=int(input()) you are converting two space separated ints to a single int def avg(s,n): sum1=0 sum2=0 for i in range(0,n): for j in range(0,2): if j%2==0: sum1+=s[i][j] else: sum2+=s[i][j] print((float)(sum1/n)) print((float)(sum2/n)) n=int(input()) c=2 # I am going to ask for user input n … Read more

[Solved] How can I start writing a program in python where it reads an excel file with few records and generate more record for testing purpose

How can I start writing a program in python where it reads an excel file with few records and generate more record for testing purpose solved How can I start writing a program in python where it reads an excel file with few records and generate more record for testing purpose

[Solved] Trouble with Personal project code (replacing characters) [closed]

In python, tuples are defined with tup = (val1,val2,…). This is what you’re doing when you define wholeAssDocumentation. Since tuples don’t have a re method, you’re getting that error. Other than that, I suggest you read the regex documentation because that’s not how you use a regex on a string either. Also you’re overwriting the … Read more

[Solved] How to remove the last comma?

If you want to do it your way: for i in range(1, 21): print(i, end=”,” if i!=20 else “” ) Output: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 But a better way of doing this would be: print(*range(1, 21), sep=”,”) solved How to remove the last comma?

[Solved] Dataframe: Computed row based on cell above and cell on the left

I think you need Series.cumsum with select last row (total row) by DataFrame.iloc: df = pd.DataFrame({ ‘B’:[4,5,4], ‘C’:[7,8,9], ‘D’:[1,3,5], ‘E’:[5,3,6], }) df.loc[‘sum’] = df.sum() df.loc[‘cumsum’] = df.iloc[-1].cumsum() #if need only cumsum row #df.loc[‘cumsum’] = df.sum().cumsum() print (df) B C D E 0 4 7 1 5 1 5 8 3 3 2 4 9 5 … Read more

[Solved] How can I remove a key:value pair wherever the chosen key occurs in a deeply nested dictionary? [duplicate]

Trick The trick is to find out in advance whether a target_key is among the next children (= this_dict[key] = the values of the current dict iteration) before you reach the child level recursively. Only then you can still delete a key:value pair of the child level while iterating over a dictionary. Once you have … Read more

[Solved] write the folder path for it [closed]

@Monso, as per your provided inputs, expected outputs in problem & in comments, I’ve written the code to solve your problem. In my case: Input directory: C:\Users\pc-user\Desktop\Input Output directory: C:\Users\pc-user\Desktop\Output And I have 3 file A.txt, B.txt & C.txt inside Input directory with contents as follows. You’ve to use your own paths as you’ve mentioned … Read more