Tuesday 20 September 2016

Program to find the even elements in List - Python

This is the practice python 7th exercise.

Exercise:

Let’s say I give you a list saved in a variable: a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]. Write one line of Python that takes this list a and makes a new list that has only the even elements of this list in it.


Solution;


The solution is simple if you use list comprehension.


 


Output:





GitHub reference:


Github code:


https://gist.github.com/pinkpretty/48c8e0a700017c54d3352ca12d4117f5


Happpy coding ! :)

1 comment:

  1. Casinos Near Harrah's Resort Atlantic City - Mapyro
    Find the closest casino 평택 출장마사지 to Harrah's Resort 안양 출장안마 Atlantic City in real time 김해 출장샵 at Mapyro. Hotels 1 - 여수 출장안마 12 of 62 — Looking for Casinos Near Harrah's Resort Atlantic City in 대구광역 출장마사지 real

    ReplyDelete