mirror of
https://github.com/theoludwig/programming-challenges.git
synced 2025-05-18 12:02:53 +02:00
build(deps): update latest
This commit is contained in:
@ -1,22 +1,23 @@
|
||||
string = input()
|
||||
|
||||
def isalphanum(character: str)->bool:
|
||||
|
||||
def is_alphanumeric(character: str) -> bool:
|
||||
is_lowercase_letter = ord(character) >= ord('a') and ord(character) <= ord('z')
|
||||
is_upper_letter = ord(character) >= ord('A') and ord(character) <= ord('Z')
|
||||
is_digit = ord(character) >= ord('0') and ord(character) <= ord('9')
|
||||
return is_upper_letter or is_lowercase_letter or is_digit
|
||||
|
||||
string = string.strip(' ')
|
||||
string = string.strip('-')
|
||||
|
||||
string = string.strip(' ').strip('-')
|
||||
answer = ""
|
||||
current = ""
|
||||
|
||||
for character in string:
|
||||
if character == ' ' or (character == '-' and len(current)>0):
|
||||
if character == ' ' or (character == '-' and len(current) > 0):
|
||||
answer += current
|
||||
answer += '-'
|
||||
current = ""
|
||||
elif isalphanum(character):
|
||||
elif is_alphanumeric(character):
|
||||
current += character
|
||||
|
||||
answer += current
|
||||
|
Reference in New Issue
Block a user