code confusion
Tola Oj
ojomooluwatolami675 at gmail.com
Fri Apr 15 03:41:20 EDT 2022
i = int(input())
lis = list(map(int,input().strip().split()))[:i]
z = max(lis)
while max(lis) == z:
lis.remove(max(lis))
print (max(lis))
this is an answer to a question from the discussion chat in hackerrank. i
didn't know the answer so i found an answer that fitted well to the
question, however i struggle to understand the use of some of the methods
and functions the person has used. my major questions are: 1. what does
"[:i]" mean
2. is there
another i could write this code using if statement?
thank you
More information about the Python-list
mailing list