Programmin-in-Python

Printing a Unique pattern with strings

Nov 4th, 2021
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. string = input("Enter the string : ")
  2.  
  3. for i in range(len(string)+1):
  4.     res = string[:i] + "_"*(len(string)-i)
  5.     print(res)
  6.    
  7. # Output for "Hello World":-
  8. ___________
  9. H__________
  10. He_________
  11. Hel________
  12. Hell_______
  13. Hello______
  14. Hello _____
  15. Hello W____
  16. Hello Wo___
  17. Hello Wor__
  18. Hello Worl_
  19. Hello World
Advertisement
Add Comment
Please, Sign In to add comment