Город МОСКОВСКИЙ
00:06:31

SPLIT STRINGS - Python Codewars task for beginners

Аватар
JS Изобретения
Просмотры:
22
Дата загрузки:
29.11.2023 14:25
Длительность:
00:06:31
Категория:
Разное

Описание

00:00 Reading the task
01:00 Coding the solution
04:39 Coding the second solution

6 kyu Split Strings:
Complete the solution so that it splits the string into pairs of two characters. If the string contains an odd number of characters then it should replace the missing second character of the final pair with an underscore ('_').

Step by step solution:
1. We need to create result variable as a empty list
2. we need to create temp string as empty string
3. we will go with for loop through every character of our string
4. and add this char to our temp string
5. when the length of temp string will be 2 chars
6. we have to append temp string to our result list
7. and reset the temp string to empty string
8. and go on till the end
9. if the last char of the string is odd we have to add underscore «_» to our temp string
10. and after this, add the last item to our result

About channel:
Hi, guys! My name is Dima! I am creating beginner friendly content about python. Welcome to PYTHON PRACTICE Lessons on my channel.

Our goal is to develop coding skills in Python from BEGINNER to INTERMEDIATE level and earn money with coding - pass job interview or develop your own application, run your startup.

To boost coding skills I want to have for example a 10 days streak of coding practice!
So follow me, if you like this idea.

Рекомендуемые видео