[Solved] Why the else part is executed everytime the result is matched

The first problem: def display(self): if SearchString in per.fname: print per.fname, per.lname elif SearchString in per.lname: print per.fname, per.lname else: print “No String” if statements do not form a group of alternatives themselves. To indicate that use the elif keyword, so the else part will be executed if none of the conditions were met. In … Read more

[Solved] C# How to get all values of all rows in a dataGridView and pass it into another form

Here’s a minimal, but working example. You can pass any type, to any method… for as long as the method is expecting the type as incoming parameter. private void DoSomething(string withThisString) In that method declaration, I declared that … the method is private aka accessible to this class only the method returns void aka does … Read more

[Solved] Iterate over list

You need to break up the rows and convert each value to an integer. At the moment you are looking for the presence of the string “3” which is why strings like “2;13” pass the test. Try something like this: list_6 = [“4;99”, “3;4;8;9;14;18”, “2;3;8;12;18”, “2;3;11;18”, “2;3;8;18”, “2;3;4;5;6;7;8;9;11;12;15;16;17;18”, “2;3;4;8;9;10;11;13;18”, “1;3;4;5;6;7;13;16;17”, “2;3;4;5;6;7;8;9;11;12;14;15;18”, “3;11;18”, “2;3;5;8;9;11;12;13;15;16;17;18”, “2;5;11;18”, “1;2;3;4;5;8;9;11;17;18”, … Read more

[Solved] While (true) loop lagg [closed]

while(true) is an infinite loop, the only way of getting out of it is using break. Or changing while(true) to some condition that alternatively ends. In this code, the while(true) part makes no real sense to me, you should probably add something else to that part as well, e.g. some connection stuff etc. 6 solved … Read more

[Solved] Looping Srategies For Many Loops [closed]

32 million records is a large amount of almost anything, however if you are receiving the information from a Database perhaps there is a way to break it up into to parallel chunks. You could devise a strategy to execute a series of queries and combine the results. Take a look at the Java Future … Read more

[Solved] Creating a loop from Java input

Although it’s not entirely clear what you’re trying to achieve I have tried to modify your code from your original post to make it more readable and function the way you want. Please see my comments in the code below, I tried to prefix all of my comments with “EDIT” so you could easily identify … Read more

[Solved] Declare variables inside loops the right way?

As mentioned by πάντα ῥεῖ in the comments, you can’t create new variable names dynamically at runtime in C++. All variable names must be known at compile-time. What you need to do here is use array indices instead. For example, change somedata and Do to std::vectors. Something like this: std::vector<bool> Do(5); // contains 5 bools, … Read more

[Solved] How to refacor a code use only loops and simple arrays?

public class Anagram { public static void main(String[] args) { String text = “!Hello123 “; char[] chars = text.toCharArray(); int left = 0; int right = text.length() – 1; while (left < right) { boolean isLeftLetter = Character.isLetter(chars[left]); boolean isRightLetter = Character.isLetter(chars[right]); if (isLeftLetter && isRightLetter) { swap(chars, left, right); left++; right–; } else { … Read more