The sea does not like to be restrained.
Emektar Üye
- Katılım
- 15 Tem 2021
- Mesajlar
- 1,724
- Çözümler
- 86
- Tepki puanı
- 665
- Ödüller
- 10
- Yaş
- 25
- Sosyal
4 HİZMET YILI
In Python, strings are a sequence of characters that can be manipulated using a variety of operations. Here are some basic string operations in Python:
Concatenation (+): You can concatenate (i.e., join together) two strings using the + operator. For example, "hello" + "world" would evaluate to "helloworld".
Repetition (*): You can repeat a string a certain number of times using the * operator. For example, "hello" * 3 would evaluate to "hellohellohello".
Indexing ([]): You can access individual characters in a string using indexing. For example, "hello"[0] would evaluate to "h".
Slicing ([:]): You can extract a substring from a string using slicing. For example, "hello"[1:4] would evaluate to "ell".
Length (len()): You can determine the length of a string using the len() function. For example, len("hello") would evaluate to 5.
Case conversion (upper(), lower(), capitalize()): You can convert the case of a string using methods like upper(), lower(), and capitalize(). For example, "hello".upper() would evaluate to "HELLO".
Stripping (strip(), lstrip(), rstrip()): You can remove whitespace and other characters from the beginning and end of a string using methods like strip(), lstrip(), and rstrip(). For example, " hello ".strip() would evaluate to "hello".
These are just a few examples of basic string operations in Python. Strings are a fundamental data type in Python and there are many more operations that you can perform on them.
Concatenation (+): You can concatenate (i.e., join together) two strings using the + operator. For example, "hello" + "world" would evaluate to "helloworld".
Repetition (*): You can repeat a string a certain number of times using the * operator. For example, "hello" * 3 would evaluate to "hellohellohello".
Indexing ([]): You can access individual characters in a string using indexing. For example, "hello"[0] would evaluate to "h".
Slicing ([:]): You can extract a substring from a string using slicing. For example, "hello"[1:4] would evaluate to "ell".
Length (len()): You can determine the length of a string using the len() function. For example, len("hello") would evaluate to 5.
Case conversion (upper(), lower(), capitalize()): You can convert the case of a string using methods like upper(), lower(), and capitalize(). For example, "hello".upper() would evaluate to "HELLO".
Stripping (strip(), lstrip(), rstrip()): You can remove whitespace and other characters from the beginning and end of a string using methods like strip(), lstrip(), and rstrip(). For example, " hello ".strip() would evaluate to "hello".
These are just a few examples of basic string operations in Python. Strings are a fundamental data type in Python and there are many more operations that you can perform on them.