Q.3 Name the function used to:
1) Count the numbers of characters.
2) Obtain the first 5 characters of a string.
3) Remove the spaces at the end of the string.
4) Convert the characters to lowercase.
5) Remove the spaces at the beginning of the string.
Answers
Answered by
64
1) len()
2) string_name[:5]
3) string_name.strip()
4) string_name.lower()
5) string_name.lstrip()
Examples:
>>> s = "Python"
>>> len(s)
6
>>> s.[:5]
'Pytho'
>>> s1 = "Python "
>>> s1.strip()
'Python'
>>> s2 = "PYTHON"
>>> s2.lower()
'python'
>>> s3 = " Python"
>>> s3.lstrip()
'Python'
Similar questions