HackerRank Problem: Code works on VS Code but not on the HackerRank site

Hi, I’m trying to solve this HackerRank problem: https://www.hackerrank.com/challenges/py-set-add/problem

This is my code:

    countries = set()
    n = int(input())
    for i in range(n):
        countries.add(input())
    print(len(countries))

It works when I try it on VS Code. But gives an error – “NameError: name ‘UK’ is not defined” when I try to run the code on the HackerRank site.
What am I doing wrong here?

You’re doing nothing wrong.

HackerRank is:

Unbenannt

(switch to Python 3 and you should get sane results)

2 Likes

Thank you. That worked.