Other String Operations :- Repetition Operator (*) :-
Repetition Operator (*) का उपयोग किसी String को एक निश्चित संख्या (Number of Times) तक दोहराने (Repeat) के लिए किया जाता है।
The Repetition Operator (*) is used to repeat a string a specified number of times.
Syntax-
string * number
Example 1 -
Membership Operators (in, not in) in Python :-
Membership Operators का उपयोग यह जाँचने के लिए किया जाता है कि कोई Value (मान) किसी Sequence (क्रम) या Collection (संग्रह) जैसे String, List, Tuple, Set या Dictionary में मौजूद है या नहीं।
Membership Operators are used to check whether a value exists in a sequence or collection such as a String, List, Tuple, Set, or Dictionary.
Python has two Membership Operators:
Python में दो Membership Operators होते हैं:/ Python has two Membership Operators:
1. in Operator :-
in Operator यह जाँचता है कि कोई Value किसी Collection में मौजूद है या नहीं।
यदि Value मिल जाती है, तो परिणाम True होता है, अन्यथा False।
English:
The in operator checks whether a value exists in a collection.
If the value is found, it returns True; otherwise, it returns False.
Example :-
यदि Character या Substring मौजूद नहीं है, तो True लौटाता है।
Example -Comparison Operators दो Strings की तुलना (Compare) करते हैं। Python तुलना Unicode (Lexicographical Order) के आधार पर करता है।
EnglishComparison operators compare two strings. Python compares strings based on their Unicode (Lexicographical Order) values.
Example -4. Length Function (len())
len() Function String में मौजूद कुल Characters की संख्या लौटाता है।
EnglishThe len() function returns the total number of characters in a string.
Syntax -len(string)
Example:-