[Solved] how to start the forloop.counter from a different index

[ad_1] I’m not comfortable with Django, so I show a couple of option in plain Python, given the collections: something1 = [1,2,3,4] something2 = [1,2,3,4,5,6,7,8,9,10] You can access objects by index (not the same as database index): i = 1 for e1 in something1: print(e1) i += 1 for i2 in range(i,len(something2)): print(something2[i2]) Or slice … Read more

[Solved] how get input of multiple lines

[ad_1] Is this what you are after? >>> d=[] >>> while(True): … s=raw_input() … if s==””:break … temp = [s] … d.append(temp) … a,b,7-6,7-6,6-3 c,d,7-4,7-6,6-2 e,f,6-4,7-6,6-2 >>> d [[‘a,b,7-6,7-6,6-3’], [‘c,d,7-4,7-6,6-2’], [‘e,f,6-4,7-6,6-2’]] This makes a list item out of the input and then appends that list to your main list d You now should be able … Read more

[Solved] 2.7.6 python version needs parenthesis to print?

[ad_1] Your impression is correct, it’s not needed (unless of course you import print_function von __future__!). However, it’s not prohibited either. print is followed by an expression, and (sys.version) is a valid expression as much as sys.version is. Note that (x) does not create a tuple containing x (that would be (x,)). [ad_2] solved 2.7.6 … Read more

[Solved] Addition function in Python is not working as expected

[ad_1] You don’t need the functions nor the sum or multiply variables, just put the operation in str.format(), and you were missing the last position. # def addition(num1,num2): # return num1+num2 # def multiplication(num1,num2): # return num1*num2 print(“1.addition”) print(“2.multiplication”) choice = int(input(“Enter Choice 1/2”)) num1 = float(input(“Enter First Number:”)) num2 = float(input(“Enter Second Number:”)) # … Read more

[Solved] What is my mistake?

[ad_1] from bulbs.config import Config, DEBUG from bulbs.rexster import Graph from bulbs.titan import Graph config = Config(‘http://localhost:8182/graphs/ramgraph’) g = Graph(config) class inser_class(): ponnapu = g.vertices.create(name=”reddy”, age=”26″, state=”TELNGANA”, mobn=”111111111″) pr = g.vertices.create(name=”ramnath” ,age=”25″ , state=”TELNGANA”, mobn=”1111111″) tanu = g.vertices.create (name=”ponnapu”,age=”27″,state=”AP”,mobn=”11111111111111″) g.edges.create(pr, “knows”, tanu) g.edges.create(pr, “friends”, ponnapu) g.edges.create(ponnapu, “dontknow”,tanu) [ad_2] solved What is my mistake?

[Solved] Variable in Dictionary Value String Python

[ad_1] This should do it: My_DICT = {‘Sale_Type’ : ‘Car’, ‘Sale_Length’ : 5, “Query_String” : “”} My_DICT[‘Query_String’] = “select * from Sales where Length > %s” % My_DICT[‘Sale_Length’] — EDIT — Considering your input example, you have a list of dictionaries in My_DICT. You could do it like this: for element in My_DICT: element[‘Query_String’] = … Read more

[Solved] Conditional operator in python dictonaries and set

[ad_1] Python 2 tries to provide a sort order for almost everything; dictionaries are no exception. Dictionaries are arbitrarily but consistently ordered when compared to one another to ensure that you can sort a heterogenous list that contains them. You should not derive any meaning from their comparisons, really. Python 3 abandoned the notion that … Read more

[Solved] Python elif: syntax error

[ad_1] you end the if block in the previous line when put a instruction at the same level indentation that the if statement if condition: stuff something # doing this close the if block and a elif can only happen in a if block and you do that in if row_count == 0: for i … Read more