본문 바로가기
728x90

Checkio4

[CheckIO][Scientific Expedition] Latest-iso-datetime 1. Problem: https://py.checkio.org/en/mission/latest-iso-datetime/ 2. My solution import datetime def get_latest(dt1str: str, dt2str: str) -> str: time_comparison = [] # your code here for date in [dt1str, dt2str]: dummy_data = date.split('-') dummy_data[0] = str(int(date.split('-')[0])+3000) convert_to_unix_time = datetime.datetime.strptime("-".join(dummy_data), "%Y-%m-%dT%H:%M:%S").timestamp().. 2024. 2. 18.
[CheckIO] Replace All Occureences 1. Problem: https://py.checkio.org/en/mission/replace-all-occurrences/ 2. My solutions def replace_all(mainText: str, target: str, repl: str) -> str: # your code here return mainText.replace(target, repl) 2024. 2. 18.
[CheckIO] Convert To Title case 1. Problem: https://py.checkio.org/en/mission/convert-to-title-case/ 2. My solutions def to_title_case(sentence: str) -> str: # your code here return ' '.join([data.capitalize() for data in sentence.lower().split()]) print("Example:") print(to_title_case("hello world")) # These "asserts" are used for self-checking assert to_title_case("hello world") == "Hello World" assert to_title_case("openai .. 2024. 2. 18.
[CheckIO] Count Vowels 1. Problem: https://py.checkio.org/en/mission/count-vowels/ 2. My solutions def count_vowels(text: str) -> int: # your code here number_vowels = 0 lower_case = text.lower() for vowel in ['a','e','o','i', 'u']: number_vowels += [*lower_case].count(vowel) print(number_vowels) return number_vowels print("Example:") #print(count_vowels("Hello")) # These "asserts" are used for self-checking assert co.. 2024. 2. 18.
728x90