HackerRank input tips

In hacker rank, sometimes they give the input in 2 lines. The first line gives the number of items and the second line gives the items themselves in a list. This code snippet will help in getting those from the input:

'''
example input:
4
1 4 3 2
'''

import sys

n = int(raw_input().strip())
arr = map(int,raw_input().strip().split(' '))
'''
example input:
Input Format

The first line contains an integer, , total number of rows in the table. 
Each of the  subsequent lines contains  space-separated strings denoting a 
person's first name and email ID, respectively.
6
riya riya@gmail.com
julia julia@julia.me
'''

N = int(raw_input().strip())
for a0 in xrange(N):
    firstName,emailID = raw_input().strip().split(' ')
    firstName,emailID = [str(firstName),str(emailID)]

    # to locate "@" in this emailID string and get hold of the domain name, do this:
    emailDomain = emailID[(emailID.find("@")+1):]

Last updated

Was this helpful?