[Solved] What is wrong with my Lucky name Number python code

This should work for your purposes: name = input(“Please enter your name: “) name = name.lower() luckynumb = 0 firstnamenumb = 0 surnamenumb = 0 number = [1, 2, 3, 4, 5, 6, 7, 8, 9] row1 = [“a”, “b”, “c”, “d”, “e”, “f”, “g”, “h”, “i”] row2 = [“j”, “k”, “l”, “m”, “n”, “o”, … Read more

[Solved] Can you determine the terminating boolean expression of a for loop dynamically?

You can replace the condition in a loop with a delegate. Something like this works: int i = 0; Func<bool> predicate = () => i < 5; for (; predicate(); ++i) Console.WriteLine(i); Just assign a different delegate to predicate if you want a different condition. EDIT: This might be a clearer example: Func<int, bool> countToFive … Read more

[Solved] For loops in Java (using Arrays)

Create an array, type int, length 10. Initialize it with the multiple of 2. In your code snippet you are not Initializing the array but simply printing the values to the console. You’ll have to initialize it using either the loop or as follows: int[] values = {2, 4, 6, 8, 10, 12, 14, 16, … Read more

[Solved] Output row of Asterisks using a for-loop

Yes it is :-). You count from 0 to your value, right? So read your int before the loop and use the variable as the loop end condition: Scanner input = new Scanner(System.in); int num = input.nextInt(); for(int i =0; i<num; i++) { System.out.print(“*”); } solved Output row of Asterisks using a for-loop

[Solved] can someone explain this function to me

def look_up(to_search,target): for (index , item) in enumerate(to_search): if item == target: break # break statement here will break flow of for loop else: return(-1) # when you write return statement in function function will not execute any line after it return(index) print(“This line never be printed”) # this line is below return statement which … Read more

[Solved] for Loop commands – which is faster?

To keep it simple, in case A, your program has to initialize i only once. Assign values to i only array.Length times. Increase i values only array.Length times. do the line execution and comparison 2*array.Length times. In case B, initialize i twice. Assign values to i 2*array.Length times. Increase i values 2*array.Length times. do line … Read more

[Solved] Appeding different list values to dictionary in python

Maybe use zip: for a,b,c in zip(scores,boxes,class_list): if a >= 0.98: data[k+1] = {“score”:a,”box”:b, “class”: c } ; k=k+1; print(“Final_result”,data) Output: Final_result {2: {‘score’: 0.98, ‘box’: [0.1, 0.2, 0.3, 0.4], ‘class’: 1}} Edit: for a,b,c in zip(scores,boxes,class_list): if a >= 0.98: data[k+1] = {“score”:a,”box”:b, “class”: int(c) } ; k=k+1; print(“Final_result”,data) 9 solved Appeding different list … Read more