View difference between Paste ID: KGBQ34jG and 1dUwh0bd
SHOW: | | - or go back to the newest paste.
1
# -*- coding: UTF-8 -*-
2
def split_string_with_step(my_string, step):
3
    """
4
    create list of strings by split a big one with step
5
    """
6
    if (
7
        not isinstance(my_string, str) or
8
        not isinstance(step, int)
9
    ):
10
        raise NotImplementedError
11
    pos = 0
12
    my_list = []
13-
    for char in range(len(my_string)//step):
13+
    for char in range((len(my_string)//step)+1):
14
        my_list.append(my_string[pos:pos+step])
15
        pos+=step
16
    if len(''.join(my_list)) == len(my_string):
17
        return my_list
18
    else:
19
        raise NotImplementedError
20
21
# ~# example :
22
23-
my_list_of_string = split_string_with_step(my_string, 6)
23+
my_string_test = """MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA5qeHbZZQFLnXoiBrQb8udZxmz3FGnFFd63/qrlQ4GBpbf62DVMVEgZJOJFGEKW09KvgikBHtpRitYvW4g54s2/RVSK+6qpPq+Iw3jHuUrO3rkDW/2J5pcczUaxRQHuRyL9/fm7m9m4JMnFyTXV8Bn7hWrfH2VkVRz2wKd8BzBmMX1alCaVLLTz8NP2ccBO3U9Zyt4ZXPki5SOV3I421F9324y2VVtuqUewAGeYhGjcQ51yKlBggrkp+E1p9dmola7Xw6/UG3DIrgv88NeqAYiYjAfzMRwOjbQA2mhi770kINJKOWL59FbGcFxTcakzfdTljPHxWJy+u5aAoZNZQIDAQAB"""
24
my_list_of_string = split_string_with_step(my_string_test, 6)
25
26
for x in my_list_of_string:
27
    print(x)