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.

https://code.sololearn.com/ciHLjHaAt7Rq/?ref=app

12th Jun 2020, 3:56 AM
John Perez
John Perez - avatar
15 Answers
+ 2
Look at my profile
12th Jun 2020, 5:26 AM
Deepak
Deepak - avatar
+ 1
I have made several changes in your code
12th Jun 2020, 4:04 AM
Deepak
Deepak - avatar
+ 1
I'm not seeing a difference man, where exactly did you change anything?
12th Jun 2020, 4:11 AM
John Perez
John Perez - avatar
+ 1
I have attached your code as
12th Jun 2020, 5:27 AM
Deepak
Deepak - avatar
+ 1
John's code and then run it
12th Jun 2020, 5:27 AM
Deepak
Deepak - avatar
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)
12th Jun 2020, 4:04 AM
Deepak
Deepak - avatar
0
Kindly look to it
12th Jun 2020, 4:05 AM
Deepak
Deepak - avatar
0
Kindly compare your code with this code
12th Jun 2020, 4:12 AM
Deepak
Deepak - avatar
0
And try to run it
12th Jun 2020, 4:12 AM
Deepak
Deepak - avatar
0
You will get the difference
12th Jun 2020, 4:13 AM
Deepak
Deepak - avatar
0
And your mistakes as well
12th Jun 2020, 4:13 AM
Deepak
Deepak - avatar
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.
12th Jun 2020, 4:20 AM
John Perez
John Perez - avatar
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..
12th Jun 2020, 4:23 AM
John Perez
John Perez - avatar
0
Okay I looked at it, I'm not getting the error anymore thank you.
12th Jun 2020, 2:04 PM
John Perez
John Perez - avatar
0
Take a look at it again Deep, I got it finally thanks for your help man!
12th Jun 2020, 2:32 PM
John Perez
John Perez - avatar