-
Notifications
You must be signed in to change notification settings - Fork 50
ready_to_review #51
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?
ready_to_review #51
Conversation
|
|
||
| list1 = list(input('список=')) | ||
| k = 0 | ||
| if isinstance(list1[k], str): | ||
| k += 1 | ||
| print(k) No newline at end of file |
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.
оскільки список дано, то використання функціїї введення користувачем input() не є коректним. Поставлену задачу краще виконати так:
list1 = [65, True, 67.87, 'cola', 'pepsi', 34, 'what']
str_count = 0
for element in list1:
if isinstance(element, str):
str_count+=1
print('Кількість елементів списку типу string: ', str_count)
| import string | ||
| text1 = list(input('Введіть текст:')) | ||
| text2 = text1 | ||
| print(text2) No newline at end of file |
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.
Програма не виконує поставлене завдання. Виконання завдання слід реалізувати так:
Tim Dorotyuk, [24.12.19 01:23]
text1 = input('Введіть текст:')
text_list = text1.split()
res_list = []
for element in text_list:
res_list.append(element.capitalize())
result_string = ' '.join(res_list)
print(result_string)
| text1 = str(input('text:')) | ||
| list1 = ','.join(list(text1)) | ||
| n = 0 | ||
| if isinstance(list1[n], int): | ||
| list1.remove(str) | ||
| n += 1 | ||
| print (list1) No newline at end of file |
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.
list_text = [32434.332, 'dssd', 32234, '3234']
len_of_list = len(list_text)
for element in list_text:
if type(element) == int:
list_text.remove(element)
print(list_text)
| import re | ||
| def validator (): | ||
| text = input('Введіть дані:') | ||
| if bool(re.compile('^(Begin){1}\\n writeln{0,+}readln{0,+}(Begin){0,1} writeln{0,+}readln{0,+} end{0,1}\\n end{1}$',text)): | ||
| print ('Yes') | ||
| else: | ||
| print ('no') | ||
| validator() | ||
|
|
||
| flag = input('для запуску програми натисніть \"Enter\", щою завершити програми \"n\"') | ||
| if flag != 'n': | ||
| validator() | ||
| flag = input('для запуску програми натисніть \"Enter\", щою завершити програми \"n\"') | ||
| else: | ||
| print('Допобачення') No newline at end of file |
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.
Для того, аби програма нормально працювала, слід переписати регулярний вираз, а такжо замінити compile на match. Після цих змін програма має виглядати наступним чином:
import re
def validator ():
text = input('Введіть дані:')
if bool(re.match('[(Begin){1,2}(writeln())+(end){1,2}]',text)):
print ('Yes')
else:
print ('no')
validator()
flag = input('для запуску програми натисніть "Enter", щою завершити програми "n"')
if flag != 'n':
validator()
flag = input('для запуску програми натисніть "Enter", щою завершити програми "n"')
else:
print('Допобачення')
No description provided.