python integer value replacement in a list not working properly

I am trying to replace a few integers from a list with a specific value. However, the output which I am getting is not desirable. Is the for loop not working properly or is there some other problem? y1= [1,2,3,-1,-2,-3,-4,0,0] for i in range(len(y1)): if y1[i]<0: y1[i]==0 print(y1) output: [1, 2, 3, -1, -2, -3,… Read More python integer value replacement in a list not working properly

Why can't i convert from string to integer here?

The code is: public static bool IsValidIp(string ipAddres) { string[] sNumbers = ipAddres.Split(‘.’); int[] iNumbers = new int[sNumbers.Length]; for(int i = 0; sNumbers.Length > i; i++){ iNumbers[i] = Convert.ToInt32(sNumbers[i]); } return 255 >= iNumbers.Max(); } The error: System.FormatException : Input string was not in a correct format. I tried with several inputs like: "0.0.0.0", "12.255.56.1",… Read More Why can't i convert from string to integer here?