68.8k views
24 votes
Write a program in which the user enters a list of numbers in one line through a space (numbers from 0 to 10). The program must rearrange the last three elements of the list and move the remaining elements to the right.

Python program

User Nobady
by
8.0k points

1 Answer

9 votes

I could have misunderstood your question, but here's a program which does as i interpreted your question.

from random import shuffle

numbers = input("Enter your numbers separated by spaces (ex:'1 6 3 1 4')\\> ")

numbers = [int(n) for n in numbers.split(" ")]

final_numbers = numbers[-3:]

shuffle(final_numbers)

final_numbers += numbers[:-3]

print(final_numbers)

(I have not added any kind of negative feedback if the user decides to missuse the program)

User Regene
by
8.9k points

No related questions found

Welcome to QAmmunity.org, where you can ask questions and receive answers from other members of our community.