by CodeChum Admin
Did you know that you can also reverse lists and group them according to your liking with proper code? Let's try it to believe it.
Instructions
Input
The first line contains an odd positive integer.
The next lines contains an integer.
5
1
3
4
5
2
Output
A line containing a list.
[2,5]-[4]-[3,1]
import random
R=[]
N=int(input("Input an odd positive interger: "))
for x in range(N):
R.append(random.randint(1,5))
print("Generated random list")
print(R)
Back_list=R[::-1]
print("[",Back_list[0],Back_list[1],"]","-","[",Back_list[2],"]","-","[",Back_list[3],Back_list[4],"]")
Comments
Leave a comment