Sitemap

Print Function | HackerRank Solutions

Aug 10, 2022

--

Press enter or click to view image in full size
Print Function | HackerRank Solutions

Task

The included code stub will read an integer, n, from STDIN.

Without using any strings methods, try to print the following:

123……..n

Note that “…..” represents the consecutive values in between.

Example

Get Techy Rushabh’s stories in your inbox

Join Medium for free to get updates from this writer.

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

Sample Output 0

123

Solution — Python Print Function — Hacker Rank Solution

if __name__ == '__main__':
n = int(input())
for i in range(1,n+1):
print(i,end="")

--

--

Techy Rushabh
Techy Rushabh

Written by Techy Rushabh

Hello readers, I am Rushabh from India. Here I will post some coding solutions and project ideas. Don’t Forget to Follow Me :)