-
Notifications
You must be signed in to change notification settings - Fork 50
second task1 #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
second task1 #52
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| """ | ||
| Порахувати кількість елементів списку, що являють собою пустий список | ||
| """ | ||
|
|
||
| text = [1, [], 3, [], [], 12, [], 239] | ||
| result = text.count([]) | ||
| print(result) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| """ | ||
| Вивести всі слова рядочка, що містять велику літеру | ||
| """ | ||
|
|
||
| text = str(input()) | ||
| sth = text.split(" ") | ||
| for part in sth: | ||
| if (part[0].isupper()): | ||
| print(part) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Помилок немає. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| """ | ||
| Вивести суму усіх елементів списку, що являють собою числа, та окремо вивести рядочок, який складається з усіх рядочків | ||
| """ | ||
|
|
||
| text = [1, '2', '3', '4', 238, [], 'a', 'sth'] | ||
| result1 = 0 | ||
| result2 = str() | ||
| for value in text: | ||
| if isinstance(value, int): | ||
| result1 = result1 + value | ||
| elif isinstance(value, str): | ||
| result2 = str(result2 + ' ' + value) | ||
| print(result1) | ||
| print(result2) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Помилок немає. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| """ | ||
| Використовуючи регулярні вирази, для поданого тексту зробіть аби усі речення починалися з великої букви. | ||
| Виведіть результат. | ||
| """ | ||
|
|
||
| import re | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Замість імпортування повного re, краще використати from re import findall. |
||
|
|
||
| string = input() | ||
|
|
||
| good_sentences = re.findall('[A-Z]{1}[a-z]+\.', string) | ||
| bad_sentences = re.findall('[a-z]+\.', string) | ||
| print(good_sentences) | ||
| print(bad_sentences) | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Непотрібна функція print() після кожної дії. |
||
| void = [] | ||
|
|
||
| for element in range(len(good_sentences)): | ||
| void.append(good_sentences[element]) | ||
| print(void) | ||
|
|
||
| for element in range(len(bad_sentences)): | ||
|
|
||
| .append(bad_sentences[element]) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Незрозуміла дія додавання елементів(речень), що почитаються с маленької літери. Треба застосувати функцію .title() для початку речення з великої літери. |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Помилок немає.
У вигляді функції:
def empty_list_count(list): return list.count([])