Skip to content

Instantly share code, notes, and snippets.

@sytrus-in-github
Last active April 25, 2017 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sytrus-in-github/43c7d91230a591f306a5784d67e1746b to your computer and use it in GitHub Desktop.
Save sytrus-in-github/43c7d91230a591f306a5784d67e1746b to your computer and use it in GitHub Desktop.
template to get input from HackerRank problems for Python
# get number of tests and iterate through each tests
## Python 3
t = int(input().strip())
for _ in range(t):
## Python 2
t = int(input().strip())
for _ in range(t):
# get 1 integer
n = int(input().strip())
# get 2 integers in a line
n,k = [int(s) for s in input().strip().split()]
# get a list of integers from a line
arr = [int(s) for s in input().strip().split()]
# get a string(= a list of "char"s) from a line
s = input().strip()
# get a list of string from a line
arr = [s for s in input().strip().split()]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment