RUVIDEO
Поделитесь видео 🙏

Python Tutorial: Find The Length of a String in Python #44

📁 Обучение 👁️ 20 📅 02.12.2023

Python 3.7 Version - https://youtu.be/Apg2hO8rr5M

Find the Length of a String in Python
In this tutorial, we are going to look at how to find the length of a string in Python. This will be a short tutorial there really is not much to find a length of a string. Why would we want to find a length of a string? Say you wish to put a minimum number of characters on a string for a user's password or username. Using len() built-in function would allow us to find the len of the string if the user name or password is long enough we will allow them to use the user name or password. Of course, there is other reason why you may need to find the length of a string.

Len() Built-in Function Example
a = "This is my string and it is kinda long"
len(a)
38
print(len(a))
38
Example of Len() in Action
Above I was talking about taking a user's username and password and make sure it is long enough let's take a look at a little program that will allow us to check the username and password to see if they are long enough.

username = input("Your username? Min 4 Characters. ")
password = input("Your Password? Min 6 Characters. ")

What did we do above? First we get the username from the user using input and assign the users input a variable named username. Then we do the same for password but assign the variable a name of password. Then we use an if statement to check if the user add enough characters for the username and password. Note username must be at least four characters and password must be 6 and we check this by using the len() built-in function on variables then use comparison operators to check if they are long enough. If the username and password are long enough we print "Your Username and Password are long enough" and if not we will print "Your Username and Password are not secure enough"

If you have any questions about finding the length of string leave a comment below and I will help you out.

Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Python Tutorial: Find The Length of a String in Python #44», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.

Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.

Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!

Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.