Print Function - Python HackerRank Solution
Hello Friends, How are you? Today I am going to solve the HackerRank Print Function Problem in Python with a very easy explanation. In this article, you will get one or more approaches to solving this problem. So let's start-
{tocify} $title={Table of Contents}
HackerRank Python Print Function Solution - Problem Statement
Task
The included code stub will read an integer, n, from STDIN. Without using any string methods, try to print the following: 123……..n
Note that "..." represents the consecutive values in between.
Example
n = 5
Print the string 12345.
Input Format
The first line contains an integer n.
Constraints
1 ≤ n ≤ 150
Output Format:
Print the list of integers from 1 through n as a string, without spaces.
Sample Input 0
3 {codeBox}
Sample Output 0
123 {codeBox}
Python Print Function - Hacker Rank Solution
Approach I: Print Function HackerRank Python Solution
if __name__ == '__main__':
n = int(input())
for i in range (1, n+1):
print(i,end='')
Disclaimer: The above Problem ( Python Print Function ) is generated by Hackerrank but the Solution is Provided by MyEduWaves. This tutorial is only for Educational and Learning purposes. Authority if any queries regarding this post or website fill out the contact form.
I hope you have understood the solution to this HackerRank Problem. All these three solutions will pass all the test cases. Now visit Python Print Function Hackerrank Problem and try to solve it again.
All the Best!
Tags:
HackerRank Python