Skip to content

Commit ad1530d

Browse files
committed
fixed
1 parent 9e6f4fd commit ad1530d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

splitstr.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
#!/bin/python3
22
import sys
3+
import subprocess
4+
subprocess.check_call(["stty","-icanon"])
35
if len(sys.argv) == 1:
46
print(f"Usage: {sys.argv[0]} [chunk size]\nSplit a string by X chunk size")
57
sys.exit()
68
n = int(sys.argv[1])
79
text = input("String: ")
10+
print("Text Length:",len(text))
11+
print()
12+
print("++++++++COPY BELOW++++++++")
813
print('Str = ""')
9-
for i in range(0, len(text), n):
10-
print("Str = Str + " + '"' + text[i:i+n] + '"')
14+
#chunks = []
15+
chunks = [text[i:i+n] for i in range(0, len(text), n)]
16+
for i in chunks:
17+
print(f"Str = Str + \"{i}\"")
18+
#print(len(chunks))
19+
subprocess.check_call(["stty","icanon"])
20+
print("++++++++END++++++++")

0 commit comments

Comments
 (0)