top of page
Writer's pictureKrunal Chandan

Python #10 : List Comprehensions



Welcome all to our new blog of our first series i.e., HackerRank Python Solutions, where we provide solutions to the problems given on HackerRank Website of Python.



So we are gonna do some operations on the list data type of Python. If you know what is list and other data types then it will be easy for you, if not, then I must say first learn something about the list operations in then maybe you could understand the following code/program.



Code :

lists = [] for i in range(x+1): for j in range(y+1): for k in range(z+1): if i + j + k != n: lists.append([i, j, k]) print(lists)


Explanation : in this cold we have created a list named lists means the name of the variable is lists. Here we have used three for that is 2 to access different elements of list and in each of the element in list we have three more elements that is ignk which will be append at the end of third for in the loop of if. According to the question we don't have to put the elements that is equal to the number of n and the n might be anything. If you are not understanding this explanation don't go for it I am bad at explaining things you don't worry about it ok. Simply paste the code and do what you want.


Till then, #Coders😎

11 views0 comments

Recent Posts

See All

Last Blogg For KNBLOGGS

My last blogg about gaming from your android, or my other blogs, that I published earlier were not a big hit, not like this website or...

Comments


About Us

LOGO_MAIN.jpg

Welcome to KN Blogg, the place where we're serious about tech, finance, movies, and games. Or at least, we try to be. We're a team of self-proclaimed experts, enthusiasts, and sometimes just plain clueless individuals, who love to share our thoughts, opinions, and occasional witty remarks with the world.

Posts Archive

Tags

bottom of page