Hanwool Codes RSS Tag Admin Write Guestbook
2023-01-27 04:59:45

Print Function | HackerRank

 

Print Function | HackerRank

Learn to use print as a function

www.hackerrank.com

 

Goal

 

Print the list of integers from 1 through give n as a string, without spaces

 

 

Solution

 

To solve this problem, you can use for statement and str class to convert integer value to string object. 

 

# Print Function

if __name__ == '__main__':
    n = int(input())
    
    number = ""
    for i in range(1, n+1, 1):
        number += str(i)
        
    print(int(number))
Hanwool Codes. Designed by 코딩재개발.