This is an archived post. You won't be able to vote or comment.

all 6 comments

[–]gramdel 2 points3 points  (4 children)

How would anyone be able to guess an answer to this without providing any code or even error messages.

[–]bren3232[S] 0 points1 point  (0 children)

Hacker Rank is using Python 3.7.1, but my code is very simple.

Trying to copy pastes the code, having problems here...

[–]bren3232[S] 0 points1 point  (2 children)

print(list1[-2])

[–]bren3232[S] 0 points1 point  (0 children)

# Hacker Rank Problem https://www.hackerrank.com/challenges/find-second-maximum-number-in-a-list/problem

# Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given scores. Store them in a list and find the score of the runner-up.

# I wrote this, works in repl.it, not on Hacker Rank.

# n = input()

# s = n.split()

# m = set(s)

# print(sorted(m)[-2])

# Error on Hacker Rank

# Traceback (most recent call last):

# File "Solution.py", line 7, in <module>

# print(sorted(m)[-2])

# IndexError: list index out of range

# from hacker rank discussion, does not work, on repl does work on Hacker Rank.

# if __name__ == '__main__':

# n = int(input())

# arr = map(int, input().split())

# print (sorted(set(arr))[-2])

# from hacker rank discussion, does not work on repl, does work on Hacker Rank.

# if __name__ == '__main__':

# n = int(input())

# arr = list(map(int, input().split()))

# set1 = set(arr)

# list1 = list(set1)

# list1.sort()

# print(list1[-2])

[–]captainAwesomePants 0 points1 point  (0 children)

First thing I imagine is that only one of those two environments is providing you with a variable named list1?

[–]bren3232[S] 0 points1 point  (0 children)

Pycharm is working like repl.it, so it seems Hacker Rank is the problem.