Python - Полный Курс для Начинающих
4 способа поиска символа или подстроки в строке на Python
Введение В данной статье рассмотрим 4 способа поиска символа или подстроки в строке на Python. Использование оператора in Самый простой способ поиска символа или подстроки в строке — использовать оператор in. Он возвращает значение True, если символ или подстрока присутствуют в строке, и False в противном случае. text = "Пример текста"
substring = "текст" if substring in text:
print("Подстрока найдена") # Вывод: Подстрока найдена Использование метода find() Также для нахождения подстроки/буквы...
Python sets
In Python, a Set is an unordered collection of Unique elements. This means that a set cannot contain duplicate values. Sets are implemented using a hash table, which allows for very fast membership testing (checking if an element is in the set) and fast insertion and deletion of elements. Key Characteristics of Sets: Unordered: The elements in a set have no specific order. You cannot access elements by index like you can in a list. Unique: Sets only store unique elements. If you try to add a duplicate element, it will be ignored. Mutable: You can add or remove elements from a set after it has been created...