

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get first 100 characters of the string in Python?
The slice ( : ) operator in Python allows you to obtain a part of string. The slice operator has two operands, index of beginning of slice and end of slice.
substr = var[x:y]
In following example, three characters from 7th characters are obtained ( Python sequence uses zero based index)
>>> var="Hello how are you?" >>> str1=var[6:9] >>> str1 'how'
In order to obtain first 100 characters,
>>> str1=var[0:100]
- Related Questions & Answers
- Find the player who rearranges the characters to get a palindrome string first in Python
- How to find the first 10 characters of a string in C#?
- How to generate the first 100 Odd Numbers using C#?
- How to generate the first 100 even Numbers using C#?
- How can I get last 4 characters of a string in Python?
- Check whether second string can be formed from characters of first string in Python
- How to get first day of the week using Python?
- How to get first N characters from a MySQL column?
- How to extract the first n characters from a string using Java?
- How to extract first two characters from a string in R?
- Remove all characters of first string from second JavaScript
- JavaScript - Remove first n characters from string
- Removing first k characters from string in JavaScript
- How to get the length of a string in Python?
- How to get the size of a string in Python?
Advertisements