Computer Science, asked by simranbiramwar, 16 days ago

make a list of 10 elements and split them into middle and store them in two different lists using python

Answers

Answered by poojan
1

Language using: Python programming

In python programming, a list acts as an array that takes in any values. However, you can manipulate it to a specific type too.

Program 1: (Pre-defined list)

listt = [58, 24, 13, 15, 63, 9, 8, 81, 1, 78]

l1 = listt[:5]

l2 = listt[5:]

print(l1)

print(l2)

Output:

[58, 24, 13, 15, 63]

[9, 8, 81, 1, 78]

Program 2: Taking elements as input in a line, and printing output in the given format.

listt = list(map(int, input(). split(' '))) #or you can use range and run a loop

l1=list[:5]

l2=list[5:]

print(' '.join(l1))

print(' '.join(l2))

Input:

58 24 13 15 63 9 8 81 1 78

Output:

58 24 13 15 63

9 8 81 1 78

Learn more:

1. Write a Python function sumsquare(l) that takes a nonempty list of integers and returns a list [odd,even], where odd is the sum of squares all the odd numbers in l and even is the sum of squares of all the even numbers in l.

brainly.in/question/15473120

2. Python program to find absolute difference between the odd and even numbers in the inputted number.

brainly.in/question/11611140

Similar questions