-
Notifications
You must be signed in to change notification settings - Fork 51
Ready for codereview #43
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?
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,5 @@ | ||
| #Вивести усі порожні списки з поданого списку | ||
|
|
||
|
|
||
| L= [ 1, 2, [], 21, 22, [],1223, [], 'hi'] | ||
| print("Порожніх списків:\n", L.count( [])) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #Вивести усі слова котрі містять в слові велику букву | ||
|
|
||
| text=input("Введіть рядок\n") | ||
| words=text.split(" ") | ||
| for word in words: | ||
| if(word[0].isupper()): | ||
| print(word) | ||
|
Comment on lines
+3
to
+7
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. Можливо краще створити порожній список і додавати в нього елементи, які знаходяться у верхньому регістрі: result = [] for i in string: 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,14 @@ | ||
| #Порахувати суму САМЕ чисел в списку | ||
|
|
||
| L=[1 ,22,35,76,'hi',[],22,'Bro'] | ||
| sum=0 | ||
| string='' | ||
| for i in range(len(L)): | ||
| if (type(L[i])) == int: | ||
| sum=sum +L[i] | ||
| elif (type(L[i])) == str: | ||
| string = string + L[i] + '' | ||
| else: | ||
| print("Не працює\n",L[i]) | ||
|
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("Сума чисел\n",sum) | ||
| print("Об'єднання рядків\n",string) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #"Використовуючи регулярні вирази, для поданого нижче тексту замініть кожне входження автомобільного номеру у форматі `АА 0000 BB` на текст `[номер АА]`. Виведіть результат." | ||
|
|
||
| import re | ||
|
|
||
| numb = str(input('Введіть номер автомобіля\n')) | ||
|
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. нема сенсу писати str(input()), бо input() і так повертає str 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. Регулярний вираз виглядає не дуже,навіщо тут потрібен метод split. |
||
| numb2 = re.split('\w\d\d\d\d\w',numb) | ||
| print(numb2) | ||
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, не записувати назву змінної в одну букву
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.