Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
34 lines (29 loc) · 958 Bytes

File metadata and controls

34 lines (29 loc) · 958 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Python Program to Split the array
# and add the first part to the end
def split_and_switch(array, index):
first_part = array[:index]
last_part = array[index:]
last_part.extend(first_part)
return last_part
try:
num = int(input('Enter the size of the list : '))
user_list = []
for i in range(num):
while True:
value = input(f'Enter the {i + 1} element : ')
if value:
user_list.append(value)
break
else:
print('Please enter valid input')
split_index = int(input('Enter the splitting index : '))
if split_index:
if split_index > num:
print('The splitting index cannot be greater than the size of the lab')
else:
print('-'*50)
print(split_and_switch(user_list, split_index))
else:
print('Enter valid splitting index')
except ValueError:
print('Invalid Input')
Morty Proxy This is a proxified and sanitized view of the page, visit original site.