mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
Create codespell.yml (#1698)
* fixup! Format Python code with psf/black push * Create codespell.yml * fixup! Format Python code with psf/black push
This commit is contained in:
@ -1,17 +1,17 @@
|
||||
def split(string: str, seperator: str = " ") -> list:
|
||||
def split(string: str, separator: str = " ") -> list:
|
||||
"""
|
||||
Will split the string up into all the values seperated by the seperator (defaults to spaces)
|
||||
Will split the string up into all the values separated by the separator (defaults to spaces)
|
||||
|
||||
>>> split("apple#banana#cherry#orange",seperator='#')
|
||||
>>> split("apple#banana#cherry#orange",separator='#')
|
||||
['apple', 'banana', 'cherry', 'orange']
|
||||
|
||||
>>> split("Hello there")
|
||||
['Hello', 'there']
|
||||
|
||||
>>> split("11/22/63",seperator = '/')
|
||||
>>> split("11/22/63",separator = '/')
|
||||
['11', '22', '63']
|
||||
|
||||
>>> split("12:43:39",seperator = ":")
|
||||
>>> split("12:43:39",separator = ":")
|
||||
['12', '43', '39']
|
||||
"""
|
||||
|
||||
@ -19,7 +19,7 @@ def split(string: str, seperator: str = " ") -> list:
|
||||
|
||||
last_index = 0
|
||||
for index, char in enumerate(string):
|
||||
if char == seperator:
|
||||
if char == separator:
|
||||
split_words.append(string[last_index:index])
|
||||
last_index = index + 1
|
||||
elif index + 1 == len(string):
|
||||
|
Reference in New Issue
Block a user