Print Function Python Hackerrank solution

Admin
Print Function Python Hackerrank solution

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

Sample Output 0

123

Print Function Python Hackerrank solution

from __future__ import print_function
if __name__ == '__main__':
    n = int(raw_input())
    for i in range(1,n+1):
        print(i,end='');

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.