HackerRank- Python Text Alignment




Problem 8:

You are given a partial code that is used for generating the HackerRank Logo of variable thickness.
Your task is to replace the blank (______) with rjust, ljust or center.



  1. #Replace all ______ with rjust, ljust or center.
  2. thickness = int(input()) #This must be an odd number
  3. c = 'H'
  4. #Top Cone
  5. for i in range(thickness):
  6. print((c*i).rjust(thickness-1)+c+(c*i).ljust(thickness-1))
  7. #Top Pillars
  8. for i in range(thickness+1):
  9. print((c*thickness).center(thickness*2)+(c*thickness).center(thickness*6))
  10. #Middle Belt
  11. for i in range((thickness+1)//2):
  12. print((c*thickness*5).center(thickness*6))
  13. #Bottom Pillars
  14. for i in range(thickness+1):
  15. print((c*thickness).center(thickness*2)+(c*thickness).center(thickness*6))
  16. #Bottom Cone
  17. for i in range(thickness):
  18. print(((c*(thickness-i-1)).rjust(thickness)+c+(c*(thickness-i-1)).ljust(thickness)).rjust(thickness*6))
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


donate a cup of tea :)


Join Our Facebook Group

Share this solution






codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube