what's the use of strip() in this program?

the question is this and the answer i found out is this:-

[python 3]

 for i in range(int(input())):
n = input().strip();
counts = n.count('4') + n.count('7')
print(len(n)-counts) 

now, what’s i am not getting is what’s the use of split() here?

the code is working perfectly even without that !
i am a beginner!

.strip() function is used to prevent white spaces in input buffer, as it will strip and extract the expected input from actual input…

strip() removes all whitespace at the start and end, including spaces, tabs, newlines and carriage returns. Leaving it in doesn’t do any harm, and allows your program to deal with unexpected extra whitespace inserted into the file.

2 Likes

where is .split() in this code?

sorry it is .strip()! :stuck_out_tongue: