Answer to Question #302734 in Python for Lokesh

Question #302734

Number Game


A group of people are playing a game.They are standing and each carring a card with a number on it.These numbers in the list A. A random number S is selected.


Find out the new list of numbers after

  • S people were removed from the left.
  • S people were removed from the right.


Sample Input1

1,2,3

1

Sample Output1

2 3

1 2


1
Expert's answer
2022-03-01T07:12:21-0500
import random

print('Enter numbers in the list A (sep. ","): ', end='')
A = input().split(',')
#  if need manual enter random number S
#  print('Enter random number S: ', end='')
#  S = int(input())
S = random.randint(1, len(A)-1)
print(f'Random number S: {S}')
for i in range(S, len(A)):
    print(A[i], end=' ')
print()
for i in range(0, len(A)-S):
    print(A[i], end=' ')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS