Saturday, June 27, 2020

Print Function-HackerRank Solution

 Print Function-HackerRank Solution

 Read an integer .

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

Note that "" represents the values in between.



Input Format

The first line contains an integer .

Output Format

Output the answer as explained in the task.

Sample Input 0

3

Sample Output 0

123
Print Function Solution-

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

To read more about string conversion follow this link-https://www.geeksforgeeks.org/convert-integer-to-string-in-python/

0 comments:

Post a Comment

Feel free to share your thoughts and suggestion...