list comprehension

 ## i wanna generate a list of numbers

##list(#expression#for loop# condition)
squares=[i*i for i in range(1,11)]
print(squares)
##if i**i then i=n upto n times
multiply=[i**i for i in range(1,11)]
print(multiply)

"C:\Users\darul Haram\PycharmProjects\pythonProject2\venv\Scripts\python.exe" "C:/Users/darul Haram/PycharmProjects/pythonProject2/venv/Lib/list comprehension.py"
[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
[1, 4, 27, 256, 3125, 46656, 823543, 16777216, 387420489, 10000000000]

Process finished with exit code 0

Comments

Popular posts from this blog

XAMPP, SQL BASIC COMMANDS

The Minion Game Hackerrank Solution

Arrays - DS | HackerRank Solutions