I have two questions.
First Question:
I would like to know how I can remove each second element and third element from a 2-D list questions, so that if the variable questions initially is as follows:
>>> questions
>>> [['Johny', 'Baby', 'Shaw', '1984'], ['Andrew', 'fJKC', 'cbv bv', '1975'], ['Harry', 'Jack', 'Son', '1993']]
The resulted outcome becomes:
>>> questions
>>> [['Johny', '1984'], ['Andrew', '1975'], ['Harry', '1993']]
Second Question:
How can I find a way knowing two values: (minimum value, maximum value), to print whatever of the three lists in the list questions which the last element is in the range (minimum value, max value).
Expected outcome:
If, following obviously the previous outcome, for example, the minimum value is 1980
and the maximum value is 2000
. It prints the following:
>>> ['Johny', '1984'], ['Harry', '1993']
Here's my attempt:
beginning = int(input('Beginning: '))
ending = int(input('Ending: '))
position = []
for anyitem in range((len(questions)-1)):
position1 = int(questions[anyitem][2][-4:])
if beginning < position1 < ending:
print(questions[anyitem][3])
else:
pass
Please, do not use numpy
or any functions that need to be imported. Also, please make the solution general, so it can be applied to a 2D list with not only 3 elements (as in my case) but many elements (for everyone).