Python Forum
HackerRank Problem: Code works on VS Code but not on the HackerRank site
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HackerRank Problem: Code works on VS Code but not on the HackerRank site
#1
Hi, I'm trying to solve this HackerRank problem: https://www.hackerrank.com/challenges/py...dd/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 run it on VS Code, but gives the following error when I try to run the code on the HackerRank site:

Error:
Traceback (most recent call last): File "Solution.py", line 5, in <module> countries.add(input()) File "<string>", line 1, in <module> NameError: name 'UK' is not defined
What am I doing wrong here?
.
Reply


Messages In This Thread
HackerRank Problem: Code works on VS Code but not on the HackerRank site - by Pnerd - Feb-28-2021, 06:12 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Problem Converting Tradingview Indicator to Python code kralxs 1 432 Apr-27-2024, 06:10 PM
Last Post: kralxs
  problem in output of a snippet code akbarza 2 478 Feb-28-2024, 07:15 PM
Last Post: deanhystad
  problem in running a code akbarza 7 823 Feb-14-2024, 02:57 PM
Last Post: snippsat
  My code works on Jupyter Lab/Notebook, but NOT on Visual Code Editor jst 4 1,347 Nov-15-2023, 06:56 PM
Last Post: jst
  problem In using functools in a code akbarza 7 1,232 Oct-11-2023, 10:30 AM
Last Post: DeaD_EyE
  Problem with code / audio is playing randomly, not matching csv requirements Daniel_kcr 2 742 Sep-07-2023, 05:09 PM
Last Post: deanhystad
  Problem with my code slowing down and crashing SuchUmami 1 566 Jul-21-2023, 10:09 AM
Last Post: Gribouillis
  Code problem - probably easy fix? colin_dent 5 1,024 Jun-30-2023, 01:55 PM
Last Post: deanhystad
  Code works but doesn't give the right results colin_dent 2 825 Jun-22-2023, 06:04 PM
Last Post: jefsummers
  Code used to work 100%, now sometimes works! muzicman0 5 1,610 Jan-13-2023, 05:09 PM
Last Post: muzicman0

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020