Skip to content

Instantly share code, notes, and snippets.

@neonbadger
Last active July 15, 2018 15:45
Show Gist options
  • Save neonbadger/9033173b04407462621e to your computer and use it in GitHub Desktop.
Save neonbadger/9033173b04407462621e to your computer and use it in GitHub Desktop.
Hackerrank stdin & stdout for python
"""
Hackerrank: read from STDIN
raw_input: read a line from STDIN and returns a string
number per line:
n = int(raw_input())
space-seperated numbers in line:
arr = map(int, raw_input().split())
"""
def main():
t = int(raw_input())
for _ in xrange(t):
a, b = map(int, raw_input().strip().split(' '))
main()
@patientplatypus
Copy link

This doesn't work as presented

def main():
  t = int(raw_input())
  
  for _ in xrange(t):
    a, b = map(int, raw_input().strip().split(' '))
  print(a,b)
    
main()
Traceback (most recent call last):
  File "solution.py", line 8, in 
    main()
  File "solution.py", line 5, in main
    a, b = map(int, raw_input().strip().split(' '))
ValueError: need more than 1 value to unpack

Please revise or take this down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment