lost again, second function wont act right | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

lost again, second function wont act right

the purpose is to put together an ip adress and try all possible outcomes, the function for the last number isnt working, its supposed to increment 255 times for EACH increnentation of the first function who() however function lastleg() isnt incrementing at all, ive tried removing the for loop, ans also tried swapping position of if loop and the for loop, does anyone see my mistake? https://code.sololearn.com/WM6UWDRhwMHw/?ref=app

14th Jul 2017, 7:31 PM
Escobar
Escobar - avatar
6 Answers
+ 9
In addition to the @Suspicious User's answer, i don't know if can be helpful because i did not understand preciously what you want to do, but if it is something like: 120.340.0.1 120.340.0.2 ... 120.340.1.1 120.340.1.2 ... and so on checking all possible combinations, you could use a nested loop and make it a bit cleaner: https://code.sololearn.com/W5l9AYDnAC68/?ref=app Let me know if i misunderstood something. :)
14th Jul 2017, 8:30 PM
Maz
Maz - avatar
+ 1
@maz yea thats the right understanding, so i was wrong all along toabe trying to write two functions for this action, i should have stuck with a nested loop from the beginning, thanks im gonna try to plug everything in and see if it all works itself out, thanks a bunch
14th Jul 2017, 8:34 PM
Escobar
Escobar - avatar
+ 1
@maz it worked like a charm, your a chick??
14th Jul 2017, 8:44 PM
Escobar
Escobar - avatar
+ 1
@suspicioususer, thanks bro, didnt understand quite as well but i kno i will afte i read it 5 or 6 try times, taking a screenshot of it now...
14th Jul 2017, 8:59 PM
Escobar
Escobar - avatar
0
it worked, well i havent fully succeeded but it did make my lastleg function carryout in my out put, but could you explain to me y the return statement in the initial function made the second function work? i dont understand why that was the answer???
14th Jul 2017, 8:22 PM
Escobar
Escobar - avatar
0
i understand where you said if statement needs a condition and not a function but the condition i need the if statement to recognize is EACH incrementation of the who() function, does that make sense? i though the answer would be if(who()==×++) but that was wrong, im gonna try if(who()==true) or would a function in the if parameters be wrong every time??
14th Jul 2017, 8:29 PM
Escobar
Escobar - avatar