46. Problem to create a list of five consecutive numbers.

In this Python list program, we will create a list of five consecutive numbers with the help of the below-given steps.

List of five consecutive numbers:

Steps to solve the program
  1. Create a list and use the list comprehension method.
  2. With the help of the range function create a list of five consecutive numbers.
  3. Print the output to see the result.
				
					#Input list
list1 = [[5*i + j for j in range(1,6)] for i in range(4)]

#Printing output
print(list1)
				
			

Output :

				
					[[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], 
[11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]
				
			

Related Articles

Create a sublist of numbers and their squares

Insert a given string at the beginning

Leave a Comment