[Solved] List index out of range in python

[ad_1] You check for the empty line after appending the splitted line to data. .split() on an empty line returns an empty list. x[0] on an empty list produces an IndexError. data +=[line.split()] # equal to data.append([]) if line ==”: ips=[ x[0] # Access to the first element of every list in data. for x … Read more

[Solved] Looking for a string in Python [duplicate]

[ad_1] It is not entirely clear what the conditions are. Based on your comments I think you look for the following regex: r”Профессиональная ГИС \”Панорама\” \(версия 12(\.\d+){2,}, для платформы \”x(32|64)\”\)” This will match any sequence of dots and numbers after the 12. (so for instance 12.4.51.3.002 is allowed), and furthermore both x64 and x32 are … Read more

[Solved] SQL db and Combobox [closed]

[ad_1] So here we go. I will help you with such task. First get list of databases. Then get list of tables (parameter is Connection string, where you should add the name of the database you have choosen in your combobox. public List<string> GetDatabaseList() { List<string> list = new List<string>(); string conString = “Data Source=yourDataSource; … Read more

[Solved] Getting the first date from what a user has selected

[ad_1] First you need to create an enumeration for the weekdays: extension Date { enum Weekday: Int { case sunday = 1, monday, tuesday, wednesday, thursday, friday, saturday } } Second create an extension to return the next weekday desired: extension Date { var weekday: Int { return Calendar.current.component(.weekday, from: self) } func following(_ weekday: … Read more

[Solved] How to catch all the iteration of a “for” loop in a list?

[ad_1] If you want to get the results of every iterations of a for loop into a list, you need a list to store the values at each iteration. import ipaddress user_input = input(“”) network = ipaddress.IPv4Network(user_input) ipaddresses = [] #initiate an empty list for i in network.hosts(): ipaddresses.append(i) print(ipaddresses) [ad_2] solved How to catch … Read more

[Solved] Answer by python language [closed]

[ad_1] def perfect(x): factor_sum = 0 for i in range(1, x-1): if x % i == 0: factor_sum = factor_sum + i if(factor_sum == x): return True return False print perfect(6) #Prints True print perfect(12) #Prints False print perfect(28) #Prints True [ad_2] solved Answer by python language [closed]

[Solved] Question >> print “True” or “False” if the string contains two or more characters

[ad_1] public class Demo { public static boolean contains(String str,char c){ //todo:check str for NullPointExecption int flag=0; for(int i=0;i<str.length();i++){ if(c==str.charAt(i)){ flag++; //if str contains char c,flag=flag+1 } if(flag>=2){ return true; //if flag>=2,return true } } return false; } public static void main(String[] args) { System.out.println(contains(“appple”, ‘p’));//result is true } } 7 [ad_2] solved Question >> … Read more

[Solved] Json object with attributes + array, how to move the attributes inside the array?

[ad_1] try this: const data = { “server”:”S1″, “timestamp”:”123456″, “data”:[ {“device”:”D1″, “price”:”50″}, {“device”:”D2″, “price”:”60″}, {“device”:”D3″, “price”:”70″} ] } result = {data: data.data.map(res=>({…res, …{‘timestamp’: data.timestamp, ‘server’: data.server} }))} console.log(result); 1 [ad_2] solved Json object with attributes + array, how to move the attributes inside the array?

[Solved] How to merge list of dictionaries in python in shortest and fastest way possible?

[ad_1] One of the shortest way would be to prepare a list/set of all the keys from all the dictionaries and call that key on all the dictionary in the list. list_of_dict = [{‘a’: 1, ‘b’: 2, ‘c’: 3}, {‘a’: 3, ‘b’: 5}, {‘k’: 5, ‘j’: 5}, {‘a’: 3, ‘k’: 5, ‘d’: 4}, {‘a’: 3}] … Read more

[Solved] The type or namespace name ‘Linq’ does not exist in the namespace ‘System’ (are you missing an assembly reference?) [closed]

[ad_1] R00T CaUsE Adding <authorization> tag with the code shown in above question would make any anonymous user from accessing any page other than Login, as each request will be redirected to LogIn Page with no other content allowed from server including basic CSS. Suggested solution 1 on the web was to add <location> tag … Read more

[Solved] Why the float variable is always 0 even though i have changed its value [closed]

[ad_1] I figure out the reason finally:It is because of the GameLayer instance A that used to register the PanGestureRecognizer and the GameLayer instance B which used to show the screen is not same instance.Such that processPanGesture() function is just change instance A’s currentPer,While what i print is instance B’s currentPe [ad_2] solved Why the … Read more