Skip to content

Lesson 2#3

Open
DosKirin wants to merge 17 commits intomasterfrom
lesson_2
Open

Lesson 2#3
DosKirin wants to merge 17 commits intomasterfrom
lesson_2

Conversation

@DosKirin
Copy link
Copy Markdown
Owner

задания 2го урока

Comment on lines +9 to +11
for el in range(int(len(my_lst)/2)):
my_lst[el], my_lst[el + 1] = my_lst [el + 1], my_lst[el]
el += 2
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Это что-то очень странное. Тестировал?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

да, работает вроде, может не так как как нужно: задаю вол-во элементов потом ввожу эти элементы

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Допустим, мы вводим 1, 2, 3, 4, 5. В резульатате попарной замены должны получить 2, 1, 4, 3, 5. У тебя выведет 2, 3, 1, 4, 5

@@ -0,0 +1,16 @@
seasons_list = int(input('Введите номер месяца'))
if seasons_list <= 12 and seasons_list >=1:
month_dict = {1: 'Январь', 2: 'Февраль', 3: 'Март', 4: 'Апрель',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Чтобы не писать условия, можно было сразу подготовить словарь, в котором ключами будут номера месяца, а значениями времена года. Тогда можно было бы сразу обращаться по ключу к нужному значению

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

без месяцев? просто 345 весна? 12 1 2 зима?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Да, можно сразу время года

insert = input('Введите предложение:')
a = insert.split(' ')
for i, el in enumerate(a,1):
if len(el) > 10:
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Условия тут излишни, можно всегда обрезать [:10] и если будет меньше, то питон это распознает и не будет ошибки

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

спасибо

a = insert.split(' ')
for i, el in enumerate(a,1):
if len(el) > 10:
el = el[0:10]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Можно не указывать нолик, он и так ставится по умолчанию. [:10]

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

принял спасибо

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants