- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Interesting facts about strings in Python
In this article, we will learn about some Interesting facts about strings in Python 3.x. Or earlier.
- Auto-detection of escape sequences
- Direct slicing
- Indexed access
This means that there is no permission of modification on <string>type and we only have read only access to the strings.
inp = 'Tutorials point' # output print(inp) # assigning a new value to a particular index in a string inp = 't' print(inp) # raises an error
TypeError: 'str' object does not support item assignment
Auto-detection of escape sequences
The strings containing backslash are automatically detected as an escape sequence.
inp = 'Tutorials point' # output print(inp+”\n”+”101”)
Tutorials point 101
We all are aware of substring method in c or c+ +, Slicing does the same operation in python. it takes two compulsory and 1 optional argument. Compulsory arguments are start index (included) and end index(not included) Optional argument is the step or say increment or decement value. By default it is 1.
inp = 'Tutorials point' # output print(inp[0:5])
As all elements are stored in a contiguous format, therefore we can access elements directly by the help of index.
inp = 'Tutorials point' # output print(inp+inp)
In this article, we learnt about Interesting facts about strings in Python 3.x. Or earlier.
- Interesting Facts about Java
- Interesting Facts about C Programming
- Interesting facts about null in Java
- Interesting facts about Array assignment in Java
- What are some interesting facts about space?
- What are the interesting facts about Computer Viruses?
- Interesting facts about Increment and Decrement operators in Java
- What are the interesting facts about the Nobel Prize?
- C++ bitset interesting facts?
- Who built the golden temple and what are some interesting facts about it?
- What are some interesting facts about World War 1 that aren't widely known?
- 10 Surprising Facts about the Human Brain
- What are some unknown facts about our body?
- What are the interesting facts of the Star Wars theme parks?
- Some Interesting Observations about C/C++ Ternary Operator