-
-
Save Manikant92/4444717f81a10ff2f1502c949328662a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#multiply elements in x with 11 using list comprehensions in python | |
y = [i*11 for i in x] | |
#above is similiar to below | |
y = [] | |
for i in x: | |
multiplication = i*11 | |
y.append(multiplication) | |
#instead of 4 lines of code, we can do same operation in one line using list comprehensions in python as shown above | |
#output: [11, 22, 33, 44, 55, 66, 77, 88, 99, 110, 121, 132, 143, 154] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment