Python Forum
This code gives error on website but none on my editor - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: This code gives error on website but none on my editor (/thread-27426.html)



This code gives error on website but none on my editor - Emekadavid - Jun-06-2020

I was doing a challenge on hacker rank about doing arrays in python. I really didn't know how to do arrays because I have not read about it. But I read about the function that was recommended by the website and tried something based on the function documentation, map. I tried the code below. The code worked fine on my editor, vs code, but it gave a runtime error on the hacker rank website. Can someone please go through it and tell me why it gave a run time error on the website.
The code is to ask a user to create an array of n items and to print the items of the array in reverse order.
In my implementation, because I did not know much about arrays, I took the elements of the array and put them into a list object, and then reversed the list. Cool on my editor but run time error on the website. Please, I need help.
#!/bin/python3

import math
import os
import random
import re
import sys



if __name__ == '__main__':
    n = int(input())
    vis = 0
    dlist = list()
    while vis < n :
        arr = list(map(int, input().rstrip().split()))
        for i in arr : 
            dlist.append(i) 
        vis += 1
    #i have the list
    #print it in reversed order
    for i in dlist[::-1] :
        print(i, end=' ')
The output of the error is:
Output:
Traceback (most recent call last): File "Solution.py", line 16, in <module> arr = list(map(int, input().rstrip().split())) EOFError: EOF when reading a line
Please, counting on you.


RE: This code gives error on website but none on my editor - buran - Jun-06-2020

I would guess it depends on what the site supply as test data and how it supply them.