We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Hiring developers?
  1. Prepare
  2. Python
  3. Introduction
  4. Print Function
  5. Discussions

Print Function

Problem
Submissions
Leaderboard
Discussions
Editorial
Tutorial

Sort 2952 Discussions, By:

recency

Please Login in order to post a comment

  • ronitjena64
    17 hours ago+ 0 comments

    import math if name == 'main': n = int(input()) a = 0 m = 10**n for i in range(1, n+1): m = math.floor(math.log10(i))+1 m = 10**m a = a*m + i print(a)

    0|
    Permalink
  • thedjr7
    1 day ago+ 0 comments

    thats how it is done without print trick

    import math
    if __name__ == '__main__':
        n = int(input())
        a = 0
        m = 10**n
        for i in range(1, n+1):
            m = math.floor(math.log10(i))+1
            m = 10**m
            a = a*m + i
        print(a)
    
    0|
    Permalink
  • athanasilva95
    2 days ago+ 0 comments

    for i in range(n): print(i + 1, end='')

    0|
    Permalink
  • Sneha__Sridharan
    4 days ago+ 0 comments

    for i in range(1, n+1): print(i, end='')

    0|
    Permalink
  • calindragomir
    5 days ago+ 0 comments

    Since this is looking for a solution without using any strings, I think even list concatenation doesn't count as a valid one. I think they are expecting more or less something along the lines of:

    if __name__ == '__main__':
        n = int(input())
        a = 0;
        for i in range(1, n+1):
            if (i > 99):
                a = a*1000 + i
            elif (i > 9):
                a = a*100 + i
            else:
                a = a*10 + i
        
        print(a)
    
    0|
    Permalink
Load more conversations

Need Help?


View tutorial
View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy