-2

enter image description here

Hello, I'm a brand new beginner in Python, I'm taking the Udemy course and I got stuck at this question. Can you guys help me and please explain to me my mistake and the solutions? Please make the explanation as simple as possible because like I said, I'm brand new. Thank you so much

Hai Vo
  • 31
  • 1
  • 1
  • 5
  • 3
    The instructions say that your function should return a list. It shouldn't print anything by itself. – Barmar Aug 08 '20 at 16:57
  • 3
    Please post your code as plain text, not an image. – Barmar Aug 08 '20 at 16:58
  • 2
    Please don't post images of code, data, or Tracebacks. Copy and paste it as text then format it as code (select it and type `ctrl-k`) ... [Discourage screenshots of code and/or errors](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors) – wwii Aug 08 '20 at 16:58
  • @Sushanth What if an even value is at an **even** position? – superb rain Aug 08 '20 at 17:08

1 Answers1

2

* will pack and unpack the list. In your case, you combines them to a tuple. More info - What does asterisk * mean in Python?

You just need to loop through them.


def myFunc(*args):
    return [i for i in args if i % 2 ==0]

print(myFunc(5,6,7,8))

Output:

[6,8]
bigbounty
  • 16,526
  • 5
  • 37
  • 65