What is String in python?
- In Python, String is a sequence of characters enclosed by either single quotes or double-quotes.
- Example: 'Python', "Geek4Tutorial"
- Strings are immutable.
- Each value in a string is called character.
Creating a String:
- Strings can be created by enclosing the sequence of characters inside a single quote or double quote and assigning it to a variable.
- Sometimes triple quotes can also be used to create a string, even though triple quotes are used to represent Multiline strings and Docstrings.
- We can access the characters(element) in the string just like the index using index position.
No comments:
Post a Comment