Another assignment
Co-authored-by: Seaswimmer <SeaswimmerTheFsh@users.noreply.github.com>
This commit is contained in:
parent
a6c0dbf000
commit
dc6b4a1a6c
4 changed files with 78 additions and 0 deletions
0
thevoices/__init__.py
Normal file
0
thevoices/__init__.py
Normal file
18
thevoices/main.py
Normal file
18
thevoices/main.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
# ANSI color codes
|
||||
BLUE = "\033[34m" # Blue
|
||||
GREEN = "\033[32m" # Green
|
||||
RESET = "\033[0m" # Reset to default color
|
||||
|
||||
|
||||
def reverse_string(string: str) -> str:
|
||||
wordlist: list[str] = string.split(" ") # Split the string by spaces into a list
|
||||
wordlist.reverse() # Reverse the word list
|
||||
return " ".join(wordlist) # Join the wordlist back into a string, with spaces between each element
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
string: str = input(
|
||||
f"{BLUE}Input a string to reverse:{RESET} "
|
||||
) # Allows us to input a string to reverse
|
||||
result: str = reverse_string(string)
|
||||
print(f"{GREEN}{result}{RESET}")
|
Loading…
Add table
Add a link
Reference in a new issue