Aug-17-2019, 02:48 PM
Hello everyone, I'm currently learning for loops right now and I did a basic program that takes string inputs and an integer input. The program will print the string and will split the strings based on the integer input. How do I make it something like this?
S = jhdsjalhdshja21dasj
N = 5
-------
|jhdsj|
|alhds|
|hja21|
|dasj |
-------
My code:
S = jhdsjalhdshja21dasj
N = 5
-------
|jhdsj|
|alhds|
|hja21|
|dasj |
-------
My code:
string = input("String = ") length = input("Length = ") for i in range(0, len(string), length): print("|",s[i:i+n,"|")