45. Problem to create a sublist of numbers and their squares

In this Python list program, we will create a sublist of numbers and their squares with the help of the below-given steps.

Create a sublist of numbers:

Steps to solve the program
  1. Create a list and use the list comprehension method.
  2. With the help of range, function create a sublist of numbers and their squares.
  3. Print the list to see the output.
				
					#Input list
list1 = [[i,i**2] for i in range(1,11)]

#Printing output
print(list1)
				
			

Output :

				
					[[1, 1], [2, 4], [3, 9], [4, 16], [5, 25], 
[6, 36], [7, 49], [8, 64], [9, 81], [10, 100]]
				
			

Related Articles

Print list elements separately

Create a list of five consecutive numbers