Apna Hindi Tech Website Computer science рдХреЗ Students рдФрд░ Technology рдХреЗ рдмрд╛рд░реЗ рдореЗрдВ рдЬрд╛рдирдХрд╛рд░реА рд░рдЦрдиреЗ рд╡рд╛рд▓реЗ рд▓реЛрдЧреЛрдВ рдХреЗ рд▓рд┐рдП рдмрд╣реБрдд рд▓рд╛рднрджрд╛рдпрдХ Web site рд╣реИред
рд╣рдорд╛рд░реА Website Apna Hindi Tech рдкрд░ Free рдореЗрдВ Python Programming language рд╣рд┐рдВрджреА рдореЗрдВ рд╕рд┐рдЦрд╛рдИ рдЬрд╛рддреА рд╣реИ рдФрд░ рджреБрдирд┐рдпрд╛ рдореЗрдВ рдЬреЛ рд▓реЗрдЯреЗрд╕реНрдЯ рдЯреЗрдХреНрдиреЛрд▓реЙрдЬреА(Technology) рд╣реИ рдЙрд╕рдХреЗ рдмрд╛рд░реЗ рдореЗрдВ рд╡рд┐рд╕реНрддрд╛рд░ рд╕реЗ рдмрддрд╛рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред
рджреЛрд╕реНрддреЛрдВ рд╣рдордиреЗ рдЕрдкрдиреА рд╡реЗрдмрд╕рд╛рдЗрдЯ Apna Hindi Tech рдкрд░ Python Programming рд╕реЗ рд░рд┐рд▓реЗрдЯреЗрдб рдмрд╣реБрдд рд╕рд╛рд░реЗ Softwares рдмрдирд╛рдирд╛ рднреА рд╕рд┐рдЦрд╛рдпрд╛ рд╣реИ рд╡реЛ рднреА рдЕрдкрдиреА рднрд╛рд╖рд╛ рд╣рд┐рдВрджреА рдореЗрдВред
Text Wrap Hackerrank Solution In Python 3
Hello Friends
рдЖрдЬ рд╣рдо рдЖрдкрдХреЛ Hacker Rank рдкрд░ Text Wrap рдХрд╛ рдХрдВрдкреНрд▓реАрдЯ рд╕реЙрд▓реНрдпреВрд╢рди рдмрддрд╛рдПрдВрдЧреЗ рд╡рд╣ рднреА рдЖрд╕рд╛рди рднрд╛рд╖рд╛ рдореЗрдВред рддреЛ рджреЛрд╕реНрддреЛрдВ рдЪрд▓рд┐рдП рдЬрд╛рдирддреЗ рд╣реИрдВ рд╕реЙрд▓реНрдпреВрд╢рди ред
Problem:- Text Wrap Hackerrank Solution In Python 3
You are given a string S and width W.
Your task is to wrap the string into a paragraph of width W.
Function Description
Complete the wrap function in the editor below.
wrap has the following parameters:
- string string: a long string
- int max_width: the width to wrap to
Returns
- string: a single string with newline characters ('\n') where the breaks should be
Input Format
The first line contains a string, String .
The second line contains the width,max width.
Constraints
- 0 < len(string) < 1000
- 0 < max width < len(string)
Sample Input 0
ABCDEFGHIJKLIMNOQRSTUVWXYZ
4
Sample Output 0
ABCD
EFGH
IJKL
IMNO
QRST
UVWX
YZ
Solution
import textwrap
def wrap(string, max_width):
return textwrap.fill(string,max_width)
if __name__ == '__main__':
string, max_width = input(), int(input())
result = wrap(string, max_width)
print(result)
Other Articles
DISCLAIMER:-
The above hole problem statement is given by hackerrank.com but the solution is generated by the Apna Hindi Tech authority if any of the query regarding this post or website fill the following contact form.
......Thank YouЁЯШК......
Related Posts
- Word Order Hackerrank Solution In Python 3
- Default Arguments in Python - HackerRank Solution | Easy Method
- Maximize It Hackerrank Solution Python
- Find Angle MBC Hackerrank Solution In Python
- Piling Up Hackerrank Solution In Python 3 | Easy Solution
- Polar Coordinates Hackerrank Solution Python | Polar Coordinates Hackerrank Solution
2 comments
Nice
ReplyDeleteVery simple code
ReplyDelete