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
Empty file added fedorchenkory/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions fedorchenkory/first/task 1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""
Якщо елемент списку - ще один список вивести його на єкран
"""
a = ['g', 'f', ['f','g',], ['k','l'], 'o', 3 ,True]
for i in a:
c= enumerate(i, list )#команда, яка перевіряє тип даних

Choose a reason for hiding this comment

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

Here should be a command isinstance(i,list)
c= enumerate(i, list )

if c==1:
print(i)
9 changes: 9 additions & 0 deletions fedorchenkory/first/task 2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
Заданий рядок. Вивести сумму всих цифр
"""
a = ('dsad486feaf8egjytj4jytj66')

Choose a reason for hiding this comment

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

All right. It's your code in function
def sum_of_digits(a): a = ('dsad486feaf8egjytj4jytj66') c=0 for i in a: if i in '0123456789': c+=int(i) print(c)

c=0
for i in a:
if i in '0123456789':
c+=int(i)
print(c)
6 changes: 6 additions & 0 deletions fedorchenkory/first/task 3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Заданий рядок. Вивести рядок з кожною другою літерою у верхньому регістрі
"""
a = ('Rost can\'t deal whith it')
b = len(a)
print(a.upper(b))

Choose a reason for hiding this comment

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

Here you should create for-loop and use slice-method for lists, so in each interval it'll be letter in upper register.
Use upper()
a = 'Rost can\'t deal whith it' b = len(a) new_list=[] for i in range (b): if i%2==0: a=a[:i]+a[i].upper()+a[i+1:] print(a)

22 changes: 22 additions & 0 deletions fedorchenkory/second/task 1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
Користувач воодить речення на англійській мові, розділяючи слова пробілами. Вивести список, кожний елемент якого є списком, де
перший елемент - кожне друге слово речення, а другий кількість повторів цьогого слова у реченні.
"""
import re
def find_text(text):
n= re.split(' ',text)

Choose a reason for hiding this comment

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

Nice, and some mentions for you.
You can use fin = re.findall('\w+', text) here instead of n= re.split(' ',text), so that all for-loop above could be removed
fin=[] for i in n: b=re.findall('[A-Za-z]{1,}',i) if b =='': b=' ' fin.append(b[0]) print(b)

fin=[]
for i in n:
b=re.findall('[A-Za-z]{1,}',i)
if b =='':
b=' '
fin.append(b[0])
print(b)
fin1=[]
for i in fin[::2]:
k=0
k=len(re.findall(str(i),str(fin)))
fin1.append([i,k])
return fin1
a= find_text(input())
print(a)