Created
March 29, 2020 16:39
-
-
Save Deep18-03/9272e01a6a7c091b18db7ae8398437cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''Algorithm: | |
- Create new empty list | |
- For loop to iterate over each element | |
- If element < 5: | |
- Append the element into new list | |
- Print the new list''' | |
a = [1, 1, 2, 3, 5, 2, 13, 21, 3 4, 55, 89] | |
b=[] | |
for i in a: | |
if i < 5: | |
b.append(i) | |
print(b) | |
#single line use : print([aa for aa in a if aa < 5]) concept name:list comprehension |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment