What is the use of strip() in python
there are various way in which we can explain strip
- When we use strip() then it removes all whitespaces from the beginning and the end of the string because there is nothing between the brackets.
- strip() is an inbuilt function in Python programming language that is used for removing beginning and ending character which is passed between the brackets.
Syntax:
string.strip([chars])
Example:-
Example:-
The best use of strip is in this program shown below:-
for i in range(int(input())):
n = input().strip();
counts = n.count('4') + n.count('7')
print(len(n)-counts)
0 Comments