Take Input From User
input()
allows flexibility to take the input from the user.
Reads a line of input as a string.Code
PYTHON
Input
Output
Working with Strings
String Concatenation
Joining strings together is called string concatenation.
Code
PYTHON
Output
Concatenation Errors
String Concatenation is possible only with strings.
Code
PYTHON
Output
String Repetition
*
operator is used for repeating strings any number of times as required.Code
PYTHON
Output
Code
PYTHON
Output
Length of String
len()
returns the number of characters in a given string.Code
PYTHON
Input
Output
String Indexing
We can access an individual character in a string using their positions (which start from 0) . These positions are also called as index.
Code
PYTHON
Output
IndexError
Attempting to use an index that is too large will result in an error:
Code
PYTHON