Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lanovenkoav/first/task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
Порахувати кількість елементів списку, що являють собою пустий список
"""

text = [1, [], 3, [], [], 12, [], 239]
result = text.count([])
print(result)

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([])

9 changes: 9 additions & 0 deletions lanovenkoav/first/task2.py
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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Помилок немає.
У вигляді функції:
def up_word(text):
for word in text.split(" "):
if word[0].isupper:
return word
return

15 changes: 15 additions & 0 deletions lanovenkoav/first/task3.py
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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Помилок немає.
У вигляді функції:
res1=0
res2=""
def sum_str(list):
for el in list:
if isinstance(el, int):
return res1 + el
elif isinstance(el, str):
return res2+' '+el

23 changes: 23 additions & 0 deletions lanovenkoav/second/task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Використовуючи регулярні вирази, для поданого тексту зробіть аби усі речення починалися з великої букви.
Виведіть результат.
"""

import re

Choose a reason for hiding this comment

The 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)

Choose a reason for hiding this comment

The 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])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Незрозуміла дія додавання елементів(речень), що почитаються с маленької літери. Треба застосувати функцію .title() для початку речення з великої літери.