We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I took a long time to understand what exactly they were asking. Half the challenge in this question is figuring that out.
They provide you with a random number N, given by N = int(input()).
Next they want you to loop through the range of N, and THEN they will provide you with random input() PER loop. You need to record that input, check it with list commands, and then do that command on your list. * if the list command requires additional numbers, they will be provided in the input as well ( eg. insert requires what is being inserted into the list and at what index).
For example,
N = int(input()) # This is the random number provided
Lst = [] # this is your list
For i in range(N): # here is your loop
X = input() # this is the random list command that you need to perform on your lst
If x [0] = append # notice i added index, if input length is 3, then you need to specify the index ( eg.input = [‘insert’, ‘inserted number’,’inserted index’]
Append to your lst
etc
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Lists
You are viewing a single comment's thread. Return to all comments →
I took a long time to understand what exactly they were asking. Half the challenge in this question is figuring that out.
They provide you with a random number N, given by N = int(input()).
Next they want you to loop through the range of N, and THEN they will provide you with random input() PER loop. You need to record that input, check it with list commands, and then do that command on your list. * if the list command requires additional numbers, they will be provided in the input as well ( eg. insert requires what is being inserted into the list and at what index).
For example, N = int(input()) # This is the random number provided Lst = [] # this is your list For i in range(N): # here is your loop X = input() # this is the random list command that you need to perform on your lst If x [0] = append # notice i added index, if input length is 3, then you need to specify the index ( eg.input = [‘insert’, ‘inserted number’,’inserted index’] Append to your lst etc