0
Can anyone look at my template and tell me what I'm doing wrong? I want to call the first function from the main function.
15 Respostas
+ 2
Look at my profile
+ 1
I have made several changes in your code
+ 1
I'm not seeing a difference man, where exactly did you change anything?
+ 1
I have attached your code as
+ 1
John's code and then run it
0
import sys
import random
num_list = [7, 65, 1337, 8, -2, 24, 6, 67, 54, 36, 25, 1, 42, 9, 138, 4356, 6]
def count_even(num_list):
count_even = 0
for i in num_list:
if i % 2 == 0:
count_even += 1
return "The count of even numbers in list are: ",count_even
def main(argv):
count = count_even(num_list)
error_code = 0
return error_code
if __name__ == '__main__':
error_code = main(sys.argv[1:])
print('[+] Terminated with code: ' + str(error_code))
sys.exit(error_code)
0
Kindly look to it
0
Kindly compare your code with this code
0
And try to run it
0
You will get the difference
0
And your mistakes as well
0
Okay, I saw where you moved around some lines and removed a couple if things but now I'm getting a 'return' is outside of function error.
0
Are you getting the same error too? I'm not sure myself why it would be outside the function? I made sure it's all correct..
0
Okay I looked at it, I'm not getting the error anymore thank you.
0
Take a look at it again Deep, I got it finally thanks for your help man!