Thursday, July 21, 2016

Reading Raw Input -- Hacker Rank Solution

Reading Raw Input -- Hacker Rank Solution

Task
Read a line of input from stdin and save it to a variable, . Then print the contents of  to stdout.
Input Format
A single line containing sentence .
Constraints
Output Format
Print the contents of  to stdout.
Sample Input
How many chickens does it take to cross the road?
Sample Output
How many chickens does it take to cross the road?

Reading Raw Input -- Hacker Rank Solution

In Python 2raw_input() reads a line from input, converts it to a string (stripping a trailing newline), and returns the string. 
In Python 3input() reads a line from input, converts it to a string (stripping a trailing newline), and returns the string.
Problem Tester's code :
Python 2
print raw_input()
Python 3
print(input())

1 comment:

Powered by Blogger.