-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathair00.py
47 lines (36 loc) · 1.17 KB
/
air00.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import sys
# Fonctions utilisées:
def split_string(string_to_cut: str, string_separator: list[str]) -> list[str]:
current_word: str = ""
new_list: list[str] = []
for char in string_to_cut:
if char in string_separator:
new_list.append(current_word)
current_word = ""
else :
current_word += char
if current_word != "":
new_list.append(current_word)
return new_list
# Gestion d'erreurs :
def is_valid_length(arguments: list[str]) -> bool:
if len(arguments) != 1:
print("Erreur : Merci d'indiquer un seul argument entre guillemets")
return False
return True
# Récupération de données :
def get_arguments() -> list[str]:
arguments: list[str] = sys.argv[1:]
return arguments
# Résolution :
def display_splited_chain() -> None:
string: list[str] = get_arguments()
if not is_valid_length(string):
return
string_separator: list[str] = [" ", "\n", "\t"]
string_to_cut: str = string[0]
splited_chain: list[str] = split_string(string_to_cut, string_separator)
for word in splited_chain:
print(word)
# Affichage :
display_splited_chain()